Advertisement
rdsedmundo

RUMO9S.c

Jan 7th, 2014
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. #define MAX 100
  6. #define MAX_STRING 1000
  7.  
  8. int main()
  9. {
  10.     int i;
  11.     char nums[MAX][MAX_STRING];
  12.  
  13.     for(i = 0;; i++) {
  14.         scanf("%s", nums[i]);
  15.  
  16.         if(atoi(nums[i]) == 0)
  17.             break;
  18.     }
  19.  
  20.     for(i = 0; atoi(nums[i]) != 0; i++) {
  21.         int soma = 0, grau = 0, j, __maxsize = strlen(nums[i]);
  22.  
  23.         for(j = 0; j < __maxsize; j++) {
  24.             soma += nums[i][j] - '0';
  25.             grau++;
  26.         }
  27.  
  28.         if((soma%9) == 0)
  29.             printf("%s is a multiple of 9 and has 9-degree %d.", nums[i], grau);
  30.         else
  31.             printf("%s is not a multiple of 9.", nums[i]);
  32.  
  33.         printf("\n");
  34.     }
  35.  
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement