-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrumo9teste.c
48 lines (40 loc) · 1.07 KB
/
rumo9teste.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <stdio.h>
int contadigitos(long int num, int *contador){
if(num > 0){
num = num / 10;
*contador = *contador + 1;
contadigitos(num, contador);
}
return *contador;
}
int esmultiple(long int *nEntrada, int *acumulador) {
if (*nEntrada > 0) {
*acumulador += *nEntrada % 10;
*nEntrada = *nEntrada / 10;
esmultiple(nEntrada, acumulador);
}
return *acumulador;
}
int main() {
int deposit = 0;
int i = 0;
long int num = 0;
scanf("%ld", &num);
while (num != 0){
deposit = 0;
long int copianum = num;
esmultiple(&num, &deposit);
int t = deposit;
deposit = deposit % 9;
if (deposit == 0) {
int count = 0;
int digitos = contadigitos(t, &count);
printf("%ld is a multiple of 9 and has 9-degree %d.\n", copianum, digitos);
}
else {
printf("%ld is not a multiple of 9.\n", copianum);
}
scanf("%ld", &num);
}
return 0;
}