#include<bits/stdc++.h>
using namespace std;
int rec(int sum)
{
int rem,S=0;
while(sum)
{
S=S+(sum%10);
sum=sum/10;
}
return S;
}
int main()
{
char a[2000];
int b[2000],i,j,k,n,l,sum,count,res,S;
while(1)
{
sum=0;
count=1;
S=0;
scanf("%s",a);
if(a[0]=='0'&&strlen(a)==1)
break;
else
{
l=strlen(a);
for(i=0;i<l;i++)
{
b[i]=a[i]-48;
}
for(i=0;i<l;i++)
{
sum=sum+b[i];
}
if(sum%9==0)
{
while(sum>9)
{
count++;
S=0;
while(sum>0)
{
S=S+sum%10;
sum=sum/10;
}
sum=S;
}
printf("%s is a multiple of 9 and has 9-degree %d.\n",a,count);
}
else
{
printf("%s is not a multiple of 9.\n",a);
}
}
}
return 0;
}
using namespace std;
int rec(int sum)
{
int rem,S=0;
while(sum)
{
S=S+(sum%10);
sum=sum/10;
}
return S;
}
int main()
{
char a[2000];
int b[2000],i,j,k,n,l,sum,count,res,S;
while(1)
{
sum=0;
count=1;
S=0;
scanf("%s",a);
if(a[0]=='0'&&strlen(a)==1)
break;
else
{
l=strlen(a);
for(i=0;i<l;i++)
{
b[i]=a[i]-48;
}
for(i=0;i<l;i++)
{
sum=sum+b[i];
}
if(sum%9==0)
{
while(sum>9)
{
count++;
S=0;
while(sum>0)
{
S=S+sum%10;
sum=sum/10;
}
sum=S;
}
printf("%s is a multiple of 9 and has 9-degree %d.\n",a,count);
}
else
{
printf("%s is not a multiple of 9.\n",a);
}
}
}
return 0;
}
No comments:
Post a Comment