mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Add files via upload
This commit is contained in:
parent
396a1bee86
commit
faae224e74
36
HDOJ/1013_autoAC.cpp
Normal file
36
HDOJ/1013_autoAC.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
#define MAX 10000
|
||||
char a[MAX];
|
||||
void count(int n)
|
||||
{
|
||||
int tem,sum=0;
|
||||
while(n!=0)
|
||||
{
|
||||
sum+=n%10;
|
||||
n/=10;
|
||||
}
|
||||
if(sum<10)
|
||||
{
|
||||
printf("%d\n",sum);
|
||||
}
|
||||
else
|
||||
{
|
||||
count(sum);
|
||||
}
|
||||
}
|
||||
int main()
|
||||
{
|
||||
int i,num,len;
|
||||
while(scanf("%s",a)&&a[0]!='0')
|
||||
{
|
||||
num=0;
|
||||
len=strlen(a);
|
||||
for(i=0;i<len;i++)
|
||||
{
|
||||
num+=(a[i]-'0');
|
||||
}
|
||||
count(num);
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user