题解 | #反向输出一个四位数#
反向输出一个四位数
https://www.nowcoder.com/practice/1f7c1d67446e4361bf4af67c08e0b8b0
#include <stdio.h>
int main()
{
int a,sum=0,sun=0;
scanf("%d", &a);
for (int i = 1; i <= 4;i++)
{
sun = a % 10;
a = a / 10;
sum = 10 * sum + sun;
}
printf("%04d\n", sum);
return 0;
}
int main()
{
int a,sum=0,sun=0;
scanf("%d", &a);
for (int i = 1; i <= 4;i++)
{
sun = a % 10;
a = a / 10;
sum = 10 * sum + sun;
}
printf("%04d\n", sum);
return 0;
}