Thursday 19 May 2011

10929-You can say 11

#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    char n[1010];int i=0,c;
    //freopen("in.txt","r",stdin);
    while(gets(n))
    {
        if(strcmp(n,"0")==0)
            break;
        c = n[i]-48;
        while(n[++i])
        {
            c=(c*10 + (n[i]-48))%11;
        }
        if(c)
            printf("%s is not a multiple of 11.\n",n);
        else
            printf("%s is a multiple of 11.\n",n);
        i=0;
    }
    return(0);
}

No comments:

Post a Comment