当前位置:三九宝宝网 → 宝宝教育 → 教学论文 → 正文

C语言:由键盘输入十个整数按从大到小和从小到大分别输出排序结

更新:01-04 整理:39baobao.com
字体:

[C语言课程设计 shell排序堆排序快速排序归并递归和非递归]#include#include#include#includevoid shellSort(int *a,int len) { int step; int i,j; int temp; for(step=len/2; step>0;step/=2) { for(i=step;i=0 & temp0; i--) { h...+阅读

这是你需要的东西!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

#include

void main()

{

int a[10]={0},i,j,temp;

printf("请输入10个数字\n");

for (i=0;i<10;i++)

{

scanf("%d",&a[i]);

}

for (i=0;i<9;i++)

{

for (j=i+1;j<10;j++)

{

if (a[i]>a[j])

{

temp=a[i];

a[i]=a[j];

a[j]=temp;

}

}

}

printf("小到大排序");

for (i=0;i<10;i++)

{

printf("%d ",a[i]);

}

printf("\n");

printf("大到小排序");

for (i=9;i>=0;i--)

{

printf("%d ",a[i]);

}

printf("\n");

}

这个是代码。。。。。。。。。。。。。。!!!!!!!!!!!!!!!!!!!!!!!!

这个是代码。。。。。。。。。。。。。。!!!!

这个是代码。。。。。。。。。。。。。。!!!!

本文地址:https://www.39baobao.com/show/29_22851.html

以上内容来自互联网,请自行判断内容的正确性。若本站收录的信息无意侵犯了贵司版权,请联系我们,我们会及时处理和回复,谢谢.

以下为关联文档:

用c语言解决快速排序算法不用递归自己构造一个栈,模拟递归的过程 #define push2(A,B) push(B);push(A); void quicksort(a[],l,r) { int i; stackinit();push2(l,r); while(!stackempty()) { l=pop();r=pop()...

如何用C语言编一个归并排序的程序#include "MergeSort.h"#includeusing namespace std;MergeSort::MergeSort(vector_list, int _len){ list.push_back(0); link.push_back(0); for (int i=0; ilen = _len;}//...

c语言归并排序之前写过一个模版类,这里是部分代码: void Merger<T>::sub_Merger(T * array, size_t n) { if(n == 1) //~ 递归终止 return ; else if(n == 2) //~ 递归终止 { if( array[0]...

C语言字符串数组字典排序用二维数组记录书名,再声明一个指针数组并使各元素分别指向各书名,然后对指针数组元素按其指向的书名的字典顺序排序。这样比直接拷贝书名的效率会高些。举例如下: //#include...

C语言编程解决字符串数组字典排序用二维数组记录书名,再声明一个指针数组并使各元素分别指向各书名,然后对指针数组元素按其指向的书名的字典顺序排序。这样比直接拷贝书名的效率会高些。举例如下: //#include...

c语言字符串排序#include<stdio.h> #include<string.h> #define SIZE 91 #define LIM 31 #define HALT"" void stsrt(char*strings[],int num); int main(void) { char input[LIM][SIZE]; cha...

c语言下列函数sort实现对字符串按字典顺序由小到大排序请填空答案:(1)char *p[],int n (2)*temp (3)p[j],p[j+1])>0 (4)p[j]=p[j+1] 分析:(1)由实参得知函数sort()有两个形参,根据上题得char *p[],int n。 (2)有下面语句temp=p[j]可以得到temp...

跪求C语言算法神大整数除法超简单代码通过的原理这就是一个除法运算的。你除法怎么算,它就算算的,就是一个模拟过程。只不过他用了累积减除数的方法代替了乘法的运算,这个只对应于二个数长度差不多的时候,才有效率。 首先,judge...

C语言中怎么实现两个超大整数的相加减乘除#include <string.h> #include <stdio.h> #include <stdlib.h> #define N 100 int main(int argc, char const *argv[]) { char arr[N] = {}; gets(arr); char brr[N] = {};...