18,356
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <stdlib.h>
#define N 10
int a[N];
int i;
int j;
int temp();
int main()
{
temp();
system("pause");
return 0;
}
int temp()
{
for (i=0;i<N;i++)
{
scanf_s("%d",&a[i]);//这行写错了
}
printf("\n");
for (j=0;j<N-1;j++)
{
for (i=0;i<N-j-1;i++)
{
if (a[i]>a[i+1])
{
int t=a[i];
a[i]=a[i+1];
a[i+1]=t;
}
}
}
for (i=0;i<N;i++)
{
printf("%d",a[i]);
}
return 0;
}