Created
April 29, 2013 20:46
-
-
Save fkztw/d6b0cb7bf5486b4659fa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <cstring> | |
int main (void) | |
{ | |
char s[11]; | |
while ( scanf("%s", s) != EOF && s[0] != '0' ) | |
{ | |
while ( strlen(s) != 1 ) | |
{ | |
int F = 0; | |
for ( int i = 0; i < (int)strlen(s); i++ ) | |
{ | |
F += s[i] - '0'; | |
} | |
memset(s, '\0', 11); | |
sprintf(s, "%d", F); | |
} | |
printf("%s\n", s); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment