#include<stdio.h>
#include<string.h>
int main()
{
char a[1000];
int n, m, i, j, c, l, k, t;
while(scanf("%s", a) && a[0] != 45)
{
n = c = l = 0;
m = strlen(a);
k = m - 1;
while(a[l] == '0' && l<m)
{
l++;
}
if(l == m)
break;
while(a[k] == '0' && k>=l)
{
k--;
}
for(i=l; i<=k; i++)
{
if(c%2 == 0)
{
n = n + (a[i] - 48);
c++;
}
else
{
n = n - (a[i] - 48);
c++;
}
}
t = n/11;
if(t*11== n)
{
printf("%s is a multiple of 11.\n", a);
}
else
{
printf("%s is not a multiple of 11.\n", a);
}
}
return 0;
}
#include<string.h>
int main()
{
char a[1000];
int n, m, i, j, c, l, k, t;
while(scanf("%s", a) && a[0] != 45)
{
n = c = l = 0;
m = strlen(a);
k = m - 1;
while(a[l] == '0' && l<m)
{
l++;
}
if(l == m)
break;
while(a[k] == '0' && k>=l)
{
k--;
}
for(i=l; i<=k; i++)
{
if(c%2 == 0)
{
n = n + (a[i] - 48);
c++;
}
else
{
n = n - (a[i] - 48);
c++;
}
}
t = n/11;
if(t*11== n)
{
printf("%s is a multiple of 11.\n", a);
}
else
{
printf("%s is not a multiple of 11.\n", a);
}
}
return 0;
}
Comments
Post a Comment