从键盘任意输入10个正整数,编程实现将按由大到小的顺序排序并输出。请使用TUBE c,做谢谢啊

C语言作业,写好就不挂了,开头用#include<stdioh>
2024-12-18 16:29:39
推荐回答(1个)
回答1:

#include
void main()
{
int a[10];
for (int i = 0;i < 10;i++)
scanf("%d",&a[i]);
for (int j = 0;j < 10;j++)
for (int k = j;k < 10;k++)
if (a[j] < a[k])
{
int t = a[j];
a[j] = a[k];
a[k] = t;
}
for (int z = 0;z < 10;z++)
printf("%d ",a[z]);
}