Description
输入包括5个数字,从小到大排序后输出。
Input
5个数字包括分数和小数和整数。
分数表示形式举例:1/2。
Output
从小到大排序后统一以小数形式保留两位小数输出。
Sample Input 1
0 1/1 2 3 4
Sample Output 1
0.00 1.00 2.00 3.00 4.00
#include <stdio.h>
int main()
{
int i,j;
char x;
double a[10000],t;
for(i=0;i<5;i++)
{
scanf("%lf",&a[i]);
scanf("%c",&x);
if(x=='/')
{
scanf("%lf",&t);
a[i]=a[i]/t;
}
}
for(i=0;i<5;i++)
{
for(j=i+1;j<5;j++)
{
if(a[i]>a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
for(i=0;i<5;i++)
{
printf("%.2lf ",a[i]);
}
return 0;
}