[ZJd235][UVA10929] You can say 11

題目:
http://zerojudge.tw/ShowProblem?problemid=d235

------------------------------------------------------------------------------------------------------------

#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
while(cin >> s)
{
if(s == "0")break;
int a = 0, b = 0;
for(int i=0;i<s.length();i++)
{
if(i % 2 == 0)
a = a + (s[i] - '0');
else
b = b + (s[i] - '0');
}
if((a - b) % 11 == 0)
cout << s <<" is a multiple of 11.\n";
else
cout << s <<" is not a multiple of 11.\n";
}
return 0;
}

留言

這個網誌中的熱門文章

[ZJ]a227: 三龍杯 -> 河內之塔

建立 python 環境(windows 8)

[ZJ]b513: 判斷質數-商競103