#11217: C++答案,100%AC!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


dicksobig (迪克筆所˙比隔)

學校 : 臺北市私立延平高級中學
編號 : 54477
來源 : [140.115.205.44]
最後登入時間 :
2021-10-07 15:39:32
d235. 10929 - You can say 11 -- UVa10929 | From: [203.72.178.252] | 發表日期 : 2016-07-29 14:35

#include <iostream>
#include <stdio.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
int i,sum;
char n[1001];
while(cin>>n)
{
if(n[0]=='0') break;
for(sum=i=0; n[i]!='\0'; i++)
{
sum=sum+(n[i]-'0');
i++;
if(n[i]=='\0') break;
sum=sum-(n[i]-'0');
}
if(sum%11==0) printf("%s is a multiple of 11.\n",n);
else printf("%s is not a multiple of 11.\n",n);
}

return 0;
}

 
ZeroJudge Forum