C语言求解

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

Sylvia715 @ 2023-02-09 12:07:46

#include<stdio.h>
int main()
{
    int m,a,b,c,d;
    float n;
    m = (int)(n * 10);
    a = n/100;
    b = n/10-a;
    d = m%10;
    c = m%100;
    scanf("%f",&n);
    printf("%d",d,c,b,a);
    return 0;
}

by NRDI @ 2023-02-09 12:18:53

怎么了?


by Loic_ @ 2023-02-09 12:26:04

printf只有一个%d

先处理再scanf???


by liupan2010 @ 2023-02-09 12:43:18

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

by Antibody_ @ 2023-04-29 19:27:05

@liupan2010 这样虽然顺序改变了,可是好像和浮点数没有关系了?不过是对的哎,谢谢你!


|