| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
汗,连goto都用上了呵呵#include<stdio.h>
#include<stdlib.h>
#include<memory.h>
int main(){
int n=0,length;
char input[2500];
memset(input,'0',2500);
while(scanf("%s",input) && input[0]-'0'){
int i=0;
for(;i<strlen(input);i++)
n += (input[i]-'0');
int sum = 0;
label: while(n>9 || n){
sum += n%10;
n /= 10;
}
if(sum > 9){
n = sum;
sum = 0;
goto label;
}
printf("%d\n",sum!=0?sum:n);
memset(input,'0',2500);
}
return EXIT_SUCCESS;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator