#12581:


orevokai (KaiBao)

學校 : 國立屏東高級中學
編號 : 56462
來源 : [61.216.54.155]
最後登入時間 :
2017-12-28 10:21:06
a054. 電話客服中心 -- 板橋高中教學題 | From: [114.40.245.8] | 發表日期 : 2017-08-15 09:53

#include<stdio.h>

int codeMultiply(int code_[]) {
int sum = 0;
for (int j = 0; j < 8; j++) {
sum += code_[j] * (8 - j);
}
return sum;
}

void localCodePrint(int localcode) {
switch (localcode) {
case 10:
printf("A");
break;
case 11:
printf("B");
break;
case 12:
printf("C");
break;
case 13:
printf("D");
break;
case 14:
printf("E");
break;
case 15:
printf("F");
break;
case 16:
printf("G");
break;
case 17:
printf("H");
break;
case 18:
printf("J");
break;
case 19:
printf("K");
break;
case 20:
printf("L");
break;
case 21:
printf("M");
break;
case 22:
printf("N");
break;
case 23:
printf("P");
break;
case 24:
printf("Q");
break;
case 25:
printf("R");
break;
case 26:
printf("S");
break;
case 27:
printf("T");
break;
case 28:
printf("U");
break;
case 29:
printf("V");
break;
case 30:
printf("X");
break;
case 31:
printf("Y");
break;
case 32:
printf("W");
break;
case 33:
printf("Z");
break;
case 34:
printf("I");
break;
case 35:
printf("O");
break;

}
}


int main() {
int code[9];
int i = 0;
while (scanf("%1d%1d%1d%1d%1d%1d%1d%1d%1d", &code[0], &code[1], &code[2], &code[3], &code[4], &code[5], &code[6], &code[7], &code[8]) != EOF) {

int total = 0;
int check_code = 0;

total = codeMultiply(code);
check_code = code[8];

for (int local = 10;; local++) {
if ((10 - ((local % 10 * 9) + local / 10 + total) % 10) == check_code) {
for (int start = local; start < 34;) {
localCodePrint(start);
start = start + 11;
}
printf("\n");
break;
}
}
i = 0;
code[0] = 0;
}

return 0;

}

 
ZeroJudge Forum