请问这么做代码哪里有问题,看不出来

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

DJ_Charles @ 2021-03-27 17:04:44

#include <stdio.h>
int main(){
    int f,g,s,b,x=0;
    float y=0.000;
    float m=0.0;
    scanf("%1f",&m);
    x=10*m;
    f=x%10;
    g=(x%100-f)/10;
    s=(x%1000-g*10-f)/100;
    b=x/1000; 
    y=f+0.1*g+0.01*s+0.001*b;
    printf("%3f",y);
    return 0;
}

by 李佳隽LJJ @ 2021-03-27 17:08:11

用字符串他不香吗


by 李佳隽LJJ @ 2021-03-27 17:15:00

#include <iostream>
#include <cstring>
using namespace std;
char shu[200];
int main(){
    cin>>shu;
    for(int i=strlen(shu)-1;i>=0;i--)cout<<shu[i];
    return 0;
}

by 李佳隽LJJ @ 2021-03-27 17:15:28

这不香这不香吗


by DJ_Charles @ 2021-03-27 17:23:39

@李佳隽LJJ 香,所以我的代码问题在哪


by DJ_Charles @ 2021-03-27 17:43:28

#include <stdio.h>
int main(){
    int f,g,s,b,z=0;
    float y=0.000;
    float m=0.0;
    scanf("%f",&m);
    z=10*m;
    int x=z;
    f=x%10;
    g=(x%100-f);
    s=(x%1000-g*10-f)/100;
    b=x/1000; 
    y=f+0.1*g+0.01*s+0.001*b;
    printf("%.3f",y);
    return 0;
}

by DJ_Charles @ 2021-03-27 17:46:17

改了一下,devc++上可以过了,但在这还是不行


|