Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define MAX 100
- #define MAX_STRING 1000
- int main()
- {
- int i;
- char nums[MAX][MAX_STRING];
- for(i = 0;; i++) {
- scanf("%s", nums[i]);
- if(atoi(nums[i]) == 0)
- break;
- }
- for(i = 0; atoi(nums[i]) != 0; i++) {
- int soma = 0, grau = 0, j, __maxsize = strlen(nums[i]);
- for(j = 0; j < __maxsize; j++) {
- soma += nums[i][j] - '0';
- grau++;
- }
- if((soma%9) == 0)
- printf("%s is a multiple of 9 and has 9-degree %d.", nums[i], grau);
- else
- printf("%s is not a multiple of 9.", nums[i]);
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement