C语言练习题,求三个数的输出
输入三个数,可以选择它们从小到大输出,也可以选择他们从大到小输出!
参考答案:main()
{float a,b,c;
char d;
peintf("please input 3 digits:");
scanf("%f%f%f",&a,&b,&c);
printf("\nplease chose the match of output:\nA:small to big\nB:big to small");
scanf("%c",&d);
switch(d)
{case 'A':
case 'a':if(a<b)
{t=a;a=b;b=t;}
if(a<c)
{t=a;a=c;c=t;}
if(b<c)
{t=b;b=c;c=t;}
printf("%f,%f,%f\n",a,b,c);
break;
case 'b':
case 'B':
if(a>b)
{t=a;a=b;b=t;}
if(a>c)
{t=a;a=c;c=t;}
if(b>c)
{t=b;b=c;c=t;}
printf("%f,%f,%f\n",a,b,c);
break;
}
getch();
}