📄 a.cpp
字号:
// Problem A
// http://acm.uva.es/p/v109/10922.html
// Solution by semiconductor
#include <cstdio>
#include <cstring>
using namespace std;
char buf[1001];
void
Solve(int s)
{
int deg = 1;
while ( s >= 10 ) {
int ns = 0;
while ( s ) {
ns += s % 10;
s /= 10;
}
s = ns;
++deg;
}
if ( s == 9 ) printf("%s is a multiple of 9 and has 9-degree %d.\n", buf, deg);
else printf("%s is not a multiple of 9.\n", buf);
}
int
main()
{
while ( scanf("%s", buf), strcmp(buf, "0") ) {
int s = 0;
for ( int i = 0; buf[i]; i++ ) s += buf[i] - '0';
Solve(s);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -