Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- long long num;
- void addDigits(long long x){
- long long digit,total=0;
- while(x){
- digit = x%10;
- x/=10;
- total+=digit;
- }
- printf(" %lld",total);
- if(total>9){
- addDigits(total);
- }
- }
- int main(){
- int n;
- scanf("%d",&n);
- for(int i=1;i<=n;i++){
- scanf("%lld",&num);
- printf("Case #%d:",i);
- printf(" %lld",num);
- if(num>9){
- addDigits(num);
- }
- printf("\n");
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment