snrg.net
当前位置:首页 >> 求C语言用冒泡排序法对n个数从小到大排序 >>

求C语言用冒泡排序法对n个数从小到大排序

第一个空: i=0;i0;i-- 第三个空: j=0;j

#include void sort(int a[],int n) { int i; int j; for(i=1;i

#include #include #include #define N 50void bubbleSort(int a[], int n);int main(void){int a[N] = {0}, i = 0;srand(time(NULL));for(i = 0; i < N; i++)printf("%d ", a[i] = rand() % 100);printf("\n排序后:\n");bubbleSort(a, N);for(...

int i,j,temp;for(i=0;i

#include main() { int a[10],i,j,t; printf("Input 10 numbers:\n"); for(i=0;i

#include "stdio.h"#include "string.h"int main(){ char co[10][20]={0}; char *p[10]={NULL},*tmp=NULL; int i,j; for(i=0;i

#include int main(){ int number[10] = {95, 45, 15, 78, 84, 51, 24, 12,34,23}; for (int j = 0; j < 9; j++) for (int i = 0; i < 9 - j; i++) { if(a[i] > a[i + 1]) { int temp = a[i];a[i] = a[i + 1]; a[i + 1] = temp; } } for (int...

#include #define N 12void Exchange(int *x, int *y){ int tmp = *x; *x = *y; *y = tmp;}int main(){ int i, j, a[N]; for(i = 0; i < N; ++i) scanf("%d", a+i); for(i = 0; i < N-1; i++) for(j = i+1; j < N; j++) if(a[i] > a[j]) Exchang...

代码如下(对10个整数进行升序排序): #include int main() { int i,j,t,a[10]={5,4,8,3,6,9,7,222,64,88}; //排序 for(i=1;i

#include int main() { int a[10],i,j,t; printf("请输入10个数\n"); for(i=0;i

网站首页 | 网站地图
All rights reserved Powered by www.snrg.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com