大佬帮我看看为什么只有20分

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

_Niko @ 2024-10-05 21:08:08

#include<stdio.h>
int main() {
    double x;
    scanf("%lf",&x);
    int y=(int)x;
    int a=(x-y)*10;
    int b=y/100;
    int d=y%10;
    int c=y/10-b*10;
    printf("%d.%d%d%d",a,d,c,b);
    return 0;

}

by yuechenxi130407 @ 2024-10-05 21:19:03

建议换种思路,直接把一个字符串输入,再逆序输出,不用这么麻烦


by chenhaihang @ 2024-10-05 21:19:07

#include<bits/stdc++.h> 
using namespace std; 
int main() { 
int b,c,d; 
double a,e; 
cin>>a;
b=a/100; 
c=(a-b*100)/10;
d=a-b*100-c*10; 
e=double(a-b*100-c*10-d); cout<<e*10<<"."<<d<<c<<b<<endl;
return 0; }

AC


|