數字翻轉

 avatar
user_6817964
c_cpp
2 years ago
376 B
3
Indexable
Never
#include <stdio.h> // printf
int main()
{
    int i;
    scanf_s("%d", &i);
    int i1 = i / 10000;
    i -= i1 * 10000;
    int i2 = i / 1000;
    i -= i2 * 1000;
    int i3 = i / 100;
    i -= i3 * 100;
    int i4 = i / 10;
    i -= i4 * 10;
    int i5 = i;
    int reverse = i5 * 10000 + i4 * 1000 + i3 * 100 + i2 * 10 + i1;
    printf("%d\n", reverse);
}