#12383: yee


warren (warren(爽啦))

學校 : 臺北市私立延平高級中學
編號 : 60242
來源 : [203.72.178.252]
最後登入時間 :
2018-09-07 17:15:43
d235. 10929 - You can say 11 -- UVa10929 | From: [203.72.178.252] | 發表日期 : 2017-07-20 14:44

#include <iostream>
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