用dev可以跑,但是交上去全WA了,求助

P5705 【深基2.例7】数字反转

kotori1427 @ 2020-10-02 11:42:30

#include <stdio.h>

int main()
{
    float x,y;
    int a,b,c,d;
    scanf("%f",&x);
    a=x/100;
    b=(x-100*a)/10;
    c=(x-100*a-10*b)/1;
    d=(x-100*a-10*b-c)/0.1;
    y=100*d+10*c+b+0.1*a;

    printf("%5.1f\n",y);

    return 0;

}

by XeF2 @ 2020-10-02 11:45:29

@kotori1427 不是只要反序输出就行了吗把这个数当成字符串就行了啊


by kotori1427 @ 2020-10-02 11:47:52

@pastre 啊这,是个好方法,不过我想知道我这样写错在哪


by XeF2 @ 2020-10-02 11:50:21

@kotori1427 你的程序:

输入:123.4
输出:432.1
正确输出 4.321

by kotori1427 @ 2020-10-02 11:53:09

@pastre 懂了谢谢


|