#14970: c answer


blackconqueror (boweichen)

學校 : 國立臺南第一高級中學
編號 : 58182
來源 : [220.132.250.41]
最後登入時間 :
2020-06-01 10:17:42
d235. 10929 - You can say 11 -- UVa10929 | From: [220.132.250.41] | 發表日期 : 2018-08-24 11:49

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

int main(void) {
char N[1001];
int i;
while(scanf("%s",&N)!=EOF&&N[0]!='0'){
int a=0,b=0;
for(i=0;N[i]!='\0';i++){
if(i%2==0){//1.3.5.7.9...
a+=N[i]-'0';
}else{
b+=N[i]-'0';
}
}
//printf("%d %d\n",a,b);
if(abs(a-b)%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