Arlex @ 2022-09-07 19:47:30
#include<stdio.h>
int main()
{
float sum,fex;
int a,b,c,d;
scanf("%f",&sum);
a=sum/100;
b=(sum-100*a)/10;
c=(sum-100*a-10*b)/1;
d=(sum-100*a-10*b-c)/0.1;
fex=d*1+0.1*c+0.01*b+0.001*a;
printf("%.3f",fex);
return 0;
}
为什么在输入的数里有0.1的情况下会出错
by __er @ 2022-09-07 19:53:11
reverse(a.begin(), a.end());
by Hughpig @ 2022-09-07 19:55:13
@__er c语言谢谢
by __er @ 2022-09-07 19:56:55
@Hughpig 艹,大意了
by __er @ 2022-09-07 19:58:24
啊这样不行?
printf("%c%c%c%c%c", getchar(), getchar(), getchar(), getchar(), getchar());
by __er @ 2022-09-07 20:06:45
@Arlex
by fortyyearslater @ 2022-09-07 20:06:46
@Arlex 按位拆完直接输出,不用计算和
by fortyyearslater @ 2022-09-07 20:07:14
@__er 那这不还是按序输出吗(没试过)
by __er @ 2022-09-07 20:08:58
@fortyyearslater printf
从后往前执行函数,再从前往后输出,特性
by fortyyearslater @ 2022-09-07 20:11:20
@__er 哦哦