Q10929: You can say 11

#include <iostream> //2008/4/12

int main(void)
{
long int a = 0, b = 0;
int i, l = 0;
char s[1001];
while(1)
{
cin >> s;
if (strcmp(s, "0") == 0)
break;
for(i = 0; i < strlen(s); i++)
{
if (i % 2 == 0)
a += s[i] - '0';
else
b += s[i] - '0';
}
if ((b - a) % 11 == 0)
printf("%s is a multiple of 11.\n", s);
else
printf("%s is not a multiple of 11.\n", s);
a = 0;
b = 0;
}
}

留言

這個網誌中的熱門文章

嘸蝦米文翻譯機 網頁版

Tips: PPTP client on Openwrt

PyTox: Python binding for Project-Tox the Skype Replacement