#26855: c語言:求救!!! 只有92%不知道錯在哪....


asdcloud01@gmail.com (許寅瑜)

學校 : 不指定學校
編號 : 161373
來源 : [42.75.61.3]
最後登入時間 :
2021-09-12 15:45:48
a020. 身分證檢驗 | From: [106.1.225.151] | 發表日期 : 2021-08-28 14:28

#include <stdio.h>

#include <math.h>

#include <string.h>

#include <stdlib.h>

 

int main () {

char a[10];

char tran[26] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',//9

                         'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',//9

         'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};//8

int fer[26] = {10, 11, 12, 13, 14, 15, 16, 17, 34, //9

                     18, 19, 20, 21, 22, 35, 23, 24, 25, //9

     26, 27, 28, 29, 30, 31, 32, 33};//8

int b[10];

int total = 0;

scanf("%s", &a);

for (int d = 0; d <= 25; d++) {

if(a[0] == tran[d]) {

b[0] = fer[d];

break;

}

}

for (int c = 1; c <= 9; c++) {

b[c] = a[c] - 48;

}

for (int i = 8; i >= 1; i--) {

total = total + b[i] * (9 - i);

}

total = total + b[9];

total = total + (b[0] % 10) * 9;

total = total + (b[0] - b[0] % 10) / 10;

if (total % 10 == 0) {

printf("real");

}else {

printf("fake");

}

return 0; 

}

 
#26862: Re:c語言:求救!!! 只有92%不知道錯在哪....


cges30901 (cges30901)

學校 : 不指定學校
編號 : 30877
來源 : [39.15.1.195]
最後登入時間 :
2024-12-23 09:25:32
a020. 身分證檢驗 | From: [39.11.102.36] | 發表日期 : 2021-08-28 19:55

#include

#include

#include

#include

 

int main () {

char a[10];

char tran[26] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',//9

                         'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',//9

         'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};//8

int fer[26] = {10, 11, 12, 13, 14, 15, 16, 17, 34, //9

                     18, 19, 20, 21, 22, 35, 23, 24, 25, //9

     26, 27, 28, 29, 30, 31, 32, 33};//8

int b[10];

int total = 0;

scanf("%s", &a);

for (int d = 0; d <= 25; d++) {

if(a[0] == tran[d]) {

b[0] = fer[d];

break;

}

}

for (int c = 1; c <= 9; c++) {

b[c] = a[c] - 48;

}

for (int i = 8; i >= 1; i--) {

total = total + b[i] * (9 - i);

}

total = total + b[9];

total = total + (b[0] % 10) * 9;

total = total + (b[0] - b[0] % 10) / 10;

if (total % 10 == 0) {

printf("real");

}else {

printf("fake");

}

return 0; 

}

W, X, Y錯了

W=32

X=30

Y=31

 
#26868: Re:c語言:求救!!! 只有92%不知道錯在哪....


asdcloud01@gmail.com (許寅瑜)

學校 : 不指定學校
編號 : 161373
來源 : [42.75.61.3]
最後登入時間 :
2021-09-12 15:45:48
a020. 身分證檢驗 | From: [106.1.225.151] | 發表日期 : 2021-08-29 11:46

#include

#include

#include

#include

 

int main () {

char a[10];

char tran[26] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',//9

                         'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',//9

         'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};//8

int fer[26] = {10, 11, 12, 13, 14, 15, 16, 17, 34, //9

                     18, 19, 20, 21, 22, 35, 23, 24, 25, //9

     26, 27, 28, 29, 30, 31, 32, 33};//8

int b[10];

int total = 0;

scanf("%s", &a);

for (int d = 0; d <= 25; d++) {

if(a[0] == tran[d]) {

b[0] = fer[d];

break;

}

}

for (int c = 1; c <= 9; c++) {

b[c] = a[c] - 48;

}

for (int i = 8; i >= 1; i--) {

total = total + b[i] * (9 - i);

}

total = total + b[9];

total = total + (b[0] % 10) * 9;

total = total + (b[0] - b[0] % 10) / 10;

if (total % 10 == 0) {

printf("real");

}else {

printf("fake");

}

return 0; 

}

W, X, Y錯了

W=32

X=30

Y=31

喔喔原來是錯在這哈哈哈

謝謝!!!!

 
ZeroJudge Forum