C语言求助!为什么这样写过不了

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

wangxingyuan @ 2023-10-27 10:29:39

#include<stdio.h>
int main(){
    int a,b,c,d;
    scanf("%d%d%d.%d",&a,&b,&c,&d);
    printf("%d.%d%d%d",d,c,b,a);
    return 0;

} 

by PengDave @ 2023-10-27 10:34:02

把a,b,c,d改成char类型试试看


by Terrible @ 2023-10-27 10:58:05

@wangxingyuan

#include<stdio.h>
int main(){
    int a,b,c,d;
    scanf("%1d%1d%1d.%1d",&a,&b,&c,&d);
    printf("%d.%d%d%d",d,c,b,a);
    return 0;

} 

`%1d` 表示只读入一位数字。

by wangxingyuan @ 2023-10-27 11:17:34

@Terrible 感谢!!!


|