#include<stdio.h>
#include<string.h>
#include<math.h>
//#include<stdlib.h>
int main()
{
int a,i,temp,l,j,k,tem1,sub,tem2,len,num[2000],m,n,sum1,sum2,x;
char str[2000],c;
while(gets(str))
{
sum1=0;
sum2=0;
len=strlen(str);
if((str[0]=='0')&&(str[1]=='\0'))
break;
k=1;
for(l=0;l<len;l++)
{
num[k++]=str[l]-48;
}
for(m=1;m<=k;m=m+2)
sum1=sum1+num[m];
for(n=2;n<=k;n=n+2)
sum2=sum2+num[n];
if(sum1>sum2)
sub=sum1-sum2;
else
sub=sum2-sum1;
//sub=abs(sum1-sum2);
if(sub%11==0)
printf("%s is a multiple of 11.\n",str);
else
printf("%s is not a multiple of 11.\n",str);
for(x=1;x<=k;x++)
num[x]=0;
// scanf("%c",&c);
}
return 0;
}
#include<string.h>
#include<math.h>
//#include<stdlib.h>
int main()
{
int a,i,temp,l,j,k,tem1,sub,tem2,len,num[2000],m,n,sum1,sum2,x;
char str[2000],c;
while(gets(str))
{
sum1=0;
sum2=0;
len=strlen(str);
if((str[0]=='0')&&(str[1]=='\0'))
break;
k=1;
for(l=0;l<len;l++)
{
num[k++]=str[l]-48;
}
for(m=1;m<=k;m=m+2)
sum1=sum1+num[m];
for(n=2;n<=k;n=n+2)
sum2=sum2+num[n];
if(sum1>sum2)
sub=sum1-sum2;
else
sub=sum2-sum1;
//sub=abs(sum1-sum2);
if(sub%11==0)
printf("%s is a multiple of 11.\n",str);
else
printf("%s is not a multiple of 11.\n",str);
for(x=1;x<=k;x++)
num[x]=0;
// scanf("%c",&c);
}
return 0;
}
No comments:
Post a Comment