输入2个数,按数值大小排列 为什么输出的数字前面一个都是0呢
#include "stdio.h"
void main()
{
float a,b,t;
scanf("%f,%f",&a,&b);
if(a>b){t=a;a=b;b=t;}
printf("%5.2f,%5.2f",a,b);
} 2个数?按大小排列的问题
[解决办法]
scanf的时候,你用"%f,%f"的格式,那么在输入的时候需要加一个逗号,例如:
1.2,3.45
[解决办法]
+1
[解决办法]
scanf()函数。 格式化输入函数,调用的时候什么样格式,输入的时候一同样的格式输入!
[解决办法]
google printf() 函数,看看printf("%5.2f,%5.2f",a,b); 中5.2表示什么意思
A number specifying a minimum field width. The converted argument will be printed in a field at least this wide, and wider if necessary. If the converted argument has fewer characters than the field width it will be padded on the left (or right, if left adjustment has been requested) to make up the field width. The padding character is normally space, but is 0 if the zero padding flag is present.