#include <stdio.h>
int ten(int);
int main() {
int a,suit[26] = { 10,11,12,13,14,15,16,17,34,18,19,20,21,22,35,23,24,25,26,27,28,29,32,30,31,33 };
char b[12] = { '\0' }, nu, c, sum = 0;
while(scanf("%s",b)!=EOF){
for (int i = 1; i <= 8; i++)
{
sum = sum + (9 - i) * (char)(b[i]-48);
}
c = b[0] - 'A';
nu = suit[c];
nu = ten(nu);
a = sum + nu+b[9]-48;
if (a % 10 == 0)
printf("real");
else printf("fake");
printf("\n");}
return 0;
}
int ten(int a) {
int b=0;
b = a / 10 + 9 * (a % 10);
return b;
}
#include
int ten(int);
int main() {
int a,suit[26] = { 10,11,12,13,14,15,16,17,34,18,19,20,21,22,35,23,24,25,26,27,28,29,32,30,31,33 };
char b[12] = { '\0' }, nu, c, sum = 0;
while(scanf("%s",b)!=EOF){
for (int i = 1; i <= 8; i++)
{
sum = sum + (9 - i) * (char)(b[i]-48);
}
c = b[0] - 'A';
nu = suit[c];
nu = ten(nu);
a = sum + nu+b[9]-48;
if (a % 10 == 0)
printf("real");
else printf("fake");
printf("\n");}
return 0;
}
int ten(int a) {
int b=0;
b = a / 10 + 9 * (a % 10);
return b;
}
後來有加sum=0了
#include
int ten(int);
int main() {
int a,suit[26] = { 10,11,12,13,14,15,16,17,34,18,19,20,21,22,35,23,24,25,26,27,28,29,32,30,31,33 };
char b[12] = { '\0' }, nu, c, sum = 0;
while(scanf("%s",b)!=EOF){
for (int i = 1; i <= 8; i++)
{
sum = sum + (9 - i) * (char)(b[i]-48);
}
c = b[0] - 'A';
nu = suit[c];
nu = ten(nu);
a = sum + nu+b[9]-48;
if (a % 10 == 0)
printf("real");
else printf("fake");
printf("\n");}
return 0;
}
int ten(int a) {
int b=0;
b = a / 10 + 9 * (a % 10);
return b;
}
後來有加sum=0了
可以參考一下
https://66lemon66.blogspot.com/2020/03/zerojudge-a020-c.html