poj1519
简单题,注意9的倍数的情况
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> using namespace std; #define maxn 1005 char st[maxn]; int main() { //freopen("t.txt", "r", stdin); while (scanf("%s", st), strcmp(st, "0")) { int ans = 0; int len = strlen(st); for (int i = 0; i < len; i++) ans = (ans * 10 + st[i] - '0') % 9; if (ans) printf("%d\n", ans); else printf("9\n"); } return 0; }