就是全部代码都写进main函数呗?
#include
#include
#define LEN 100 /*数组长度上限*/
#define elemType int /*元素类型*/
int main (void) {
elemType arr[LEN];
int len;
elemType temp;
int i, j;
printf ("请输入数组元素个数:");
scanf ("%d",&len);
printf ("请输入包含%d个元素的数组:\n",len);
for (i=0; iscanf ("%d",&arr[i]);
putchar ('\n');
puts ("排序后数组:");
/*升序冒泡排序*/
for (i=0; ifor (j=0;j if (arr[j] > arr[j+1]) {
temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
for (i=0; iprintf ("%d\t",arr[i]);
putchar ('\n');
getch (); /*屏幕暂留*/
free (arr);
return 0;
}
运行结果