1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-11-23 15:48:42 +00:00
202401-programming-assignments/【实践课内】6.循环结构3/7-3 个位数.c

23 lines
248 B
C
Raw Normal View History

2024-11-01 08:36:33 +00:00
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
while (n >= 10) {
int s = 0;
while (n) {
s += n % 10;
n /= 10;
}
n = s;
}
printf("%d\n", n);
return 0;
}