Replies: 0 comments 3 replies
-
感谢你的分析与代码,很精彩 |
Beta Was this translation helpful? Give feedback.
0 replies
-
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int standard[] = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
char ZtoM[] = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'};
int n;
scanf(% d, &n);
char a[18 + 1];
int flagall = 0;
for (int i = 0; i < n; i++) {
int sum = 0;
int flag1 = 1;
scanf(% s, a);
for (int i = 0; i < 17; i++)
if (isdigit(a[i])) {
sum += (a[i] - '0') * standard[i];
} else {
printf(% sn, a);
flagall = 1;
flag1 = 0;
break;
}
if (flag1) {
sum %= 11;
if (ZtoM[sum] != a[17]) {
flagall = 1;
printf(% sn, a);
}
}
}
if (flagall == 0) {
printf(ALL passed);
}
return 0;
} 不知道能不能帮我看一下,错哪里了,有一个测试点过不去 |
Beta Was this translation helpful? Give feedback.
0 replies
-
目测这个”all”的大小写造成了问题,之前就有同学被同一个问题困住了:) 同时建议今后在任何地方问问题先将代码格式整理好,比如这里支持markdown,可以利用把代码和整个问题做的更可读一些。(我把你的回复改了一下) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
https://oliverlew.github.io/PAT/Basic/1031.html
题目
Beta Was this translation helpful? Give feedback.
All reactions