#21860: WA>自己執行程式時有符合題目,但繳交時電腦顯示我的答案卻跟測試時不一樣


testTC (testTC)

學校 : 國立彰化師範大學附屬高級工業職業學校
編號 : 97082
來源 : [36.232.90.176]
最後登入時間 :
2021-12-08 12:11:00
a054. 電話客服中心 -- 板橋高中教學題 | From: [101.137.149.64] | 發表日期 : 2020-07-28 00:27

#include <stdio.h>

#include <stdlib.h>

 

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int change(char c){

if(c == 'A'){

return 10;

}else if(c == 'B'){

return 11;

}else if(c == 'C'){

return 12;

}else if(c == 'D'){

return 13;

}else if(c == 'E'){

return 14;

}else if(c == 'F'){

return 15;

}else if(c == 'G'){

return 16;

}else if(c == 'H'){

return 17;

}else if(c == 'I'){

return 34;

}else if(c == 'J'){

return 18;

}else if(c == 'K'){

return 19;

}else if(c == 'L'){

return 20;

}else if(c == 'M'){

return 21;

}else if(c == 'N'){

return 22;

}else if(c == 'O'){

return 35;

}else if(c == 'P'){

return 23;

}else if(c == 'Q'){

return 24;

}else if(c == 'R'){

return 25;

}else if(c == 'S'){

return 26;

}else if(c == 'T'){

return 27;

}else if(c == 'U'){

return 28;

}else if(c == 'V'){

return 29;

}else if(c == 'W'){

return 32;

}else if(c == 'X'){

return 30;

}else if(c == 'Y'){

return 31;

}else if(c == 'Z'){

return 33;

}

}

 

int main(int argc, char *argv[]) {

char in[9];

char w[26] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};

int n[9] = {9,8,7,6,5,4,3,2,1};

char output[9999];

int in2[10];

int a, sum, i, j, k, check;

int flag = 0;

while(scanf("%s",&in) != EOF){

for(i=0;i<=25;i++){

a = change(w[i]);

in2[0] = a / 10;

in2[1] = a % 10;

for(k=0;k<=9;k++){

in2[k+2] = in[k] - 48;

}

for(k=0;k<=9;k++){

j = in2[k+1] * n[k];

sum = sum + j;

}

sum = sum + in2[0];

check = 10 - (sum % 10);

if(check == 10){

check = 0;

}

sum = 0;

if(in2[10] == check){

output[flag] = w[i];

flag = flag + 1;

}

}

for(i=0;i<=flag-1;i++){

printf("%c", output[i]);

}

printf("\n");

memset(output,'\0',sizeof(output));

flag = 0;

}

return 0;

}

 
#21861: Re:WA>自己執行程式時有符合題目,但繳交時電腦顯示我的答案卻跟測試時不一樣


testTC (testTC)

學校 : 國立彰化師範大學附屬高級工業職業學校
編號 : 97082
來源 : [36.232.90.176]
最後登入時間 :
2021-12-08 12:11:00
a054. 電話客服中心 -- 板橋高中教學題 | From: [101.137.149.64] | 發表日期 : 2020-07-28 00:30

#include

#include

 

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int change(char c){

if(c == 'A'){

return 10;

}else if(c == 'B'){

return 11;

}else if(c == 'C'){

return 12;

}else if(c == 'D'){

return 13;

}else if(c == 'E'){

return 14;

}else if(c == 'F'){

return 15;

}else if(c == 'G'){

return 16;

}else if(c == 'H'){

return 17;

}else if(c == 'I'){

return 34;

}else if(c == 'J'){

return 18;

}else if(c == 'K'){

return 19;

}else if(c == 'L'){

return 20;

}else if(c == 'M'){

return 21;

}else if(c == 'N'){

return 22;

}else if(c == 'O'){

return 35;

}else if(c == 'P'){

return 23;

}else if(c == 'Q'){

return 24;

}else if(c == 'R'){

return 25;

}else if(c == 'S'){

return 26;

}else if(c == 'T'){

return 27;

}else if(c == 'U'){

return 28;

}else if(c == 'V'){

return 29;

}else if(c == 'W'){

return 32;

}else if(c == 'X'){

return 30;

}else if(c == 'Y'){

return 31;

}else if(c == 'Z'){

return 33;

}

}

 

int main(int argc, char *argv[]) {

char in[9];

char w[26] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};

int n[9] = {9,8,7,6,5,4,3,2,1};

char output[9999];

int in2[10];

int a, sum, i, j, k, check;

int flag = 0;

while(scanf("%s",&in) != EOF){

for(i=0;i<=25;i++){

a = change(w[i]);

in2[0] = a / 10;

in2[1] = a % 10;

for(k=0;k<=9;k++){

in2[k+2] = in[k] - 48;

}

for(k=0;k<=9;k++){

j = in2[k+1] * n[k];

sum = sum + j;

}

sum = sum + in2[0];

check = 10 - (sum % 10);

if(check == 10){

check = 0;

}

sum = 0;

if(in2[10] == check){

output[flag] = w[i];

flag = flag + 1;

}

}

for(i=0;i<=flag-1;i++){

printf("%c", output[i]);

}

printf("\n");

memset(output,'\0',sizeof(output));

flag = 0;

}

return 0;

}

 

我自己測試時 130245675 會解出FS,繳交時同一組數字卻變成AMW。明明程式碼沒變,換個地方執行結果卻不一樣



 
ZeroJudge Forum