#include<stdio.h>
#include<string.h>
int c;
int anik(int p)
{
c++;
int e = 0, t, w;
t = p;
while(p != 0)
{
w = p % 10;
e = e + w;
p = p / 10;
}
if(e != t)
{
anik(e);
}
else
return c;
}
int main()
{
long int i, j, n, m, l, a, d;
char an[1005];
while(scanf("%s", an))
{
m = strlen(an);
j = 0;
while(an[j] == 48)
{
j++;
}
if(j == m)
break;
l = m - 1;
while(an[l] == 48)
{
l--;
}
a = 0;
for(i=l;i>=j;i--)
{
a = a + (an[i] - 48);
}
if(a%9 == 0)
{
c = 0;
d = anik(a);
printf("%s is a multiple of 9 and has 9-degree %d.\n", an, c);
}
else
{
printf("%s is not a multiple of 9.\n", an);
}
}
return 0;
}
#include<string.h>
int c;
int anik(int p)
{
c++;
int e = 0, t, w;
t = p;
while(p != 0)
{
w = p % 10;
e = e + w;
p = p / 10;
}
if(e != t)
{
anik(e);
}
else
return c;
}
int main()
{
long int i, j, n, m, l, a, d;
char an[1005];
while(scanf("%s", an))
{
m = strlen(an);
j = 0;
while(an[j] == 48)
{
j++;
}
if(j == m)
break;
l = m - 1;
while(an[l] == 48)
{
l--;
}
a = 0;
for(i=l;i>=j;i--)
{
a = a + (an[i] - 48);
}
if(a%9 == 0)
{
c = 0;
d = anik(a);
printf("%s is a multiple of 9 and has 9-degree %d.\n", an, c);
}
else
{
printf("%s is not a multiple of 9.\n", an);
}
}
return 0;
}
Comments
Post a Comment