求救求救 NA: 96% 錯第九個測資
#include <stdio.h>
int main()
{
char id[11];
int letter, sum;
scanf("%s", id);
if(id[0] < 73) //A-H
{
letter = id[0] - 55;
}else if(id[0] == 73) //I
{
letter = 34;
}else if(id[0] > 73 && id[0] < 79) //J-N
{
letter = id[0] - 56;
}else if(id[0] == 79)//O
{
letter = 35;
}else if(id[0] > 79 && id[0] < 87 || id[0] == 90) //P-V && Z
{
letter = id[0] - 57;
}else if(id[0] == 87) //W
{
letter = 32;
}else if(id[0] == 88 && id[0] == 89) //X-Y
{
letter = id[0] - 58;
}
sum = (letter%10)*9 + (letter-(letter%10))/10;
for(int i = 1; id[i] != '\0'; i++)
{
sum += (id[i]-48)*(9 - i);
}
sum += (id[9]-48);
if(sum%10 == 0)
{
printf("real");
}else
{
printf("fake");
}
return 0;
}
先感謝各位大神!!!