吃鸡割草:C语言编程
来源:百度文库 编辑:高校问答 时间:2024/10/07 01:12:05
编写一个C程序,输入20个数,按降序输出。
void sort(double a[20])
{
double temp=0;
for(int i=0;i<20;i++)
{
for(int j=i;j<20;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}//end of if
}//end of the inner circle
}//end of the outside circle
//接着依次输出数组中的数
for(int i=0;i<20;i++)
{
printf("lf%",a[i]);
}
}
祝你好运!