#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[])
{
int temp ,sum;
char id_num[10];
scanf("%s",&id_num[0]);
switch(id_num[0])
{
case 'A':sum=1;break;
case 'B':sum=10;break;
case 'C':sum=19;break;
case 'D':sum=28;break;
case 'E':sum=37;break;
case 'F':sum=46;break;
case 'G':sum=55;break;
case 'H':sum=64;break;
case 'I':sum=39;break;
case 'J':sum=73;break;
case 'K':sum=82;break;
case 'L':sum=2;break;
case 'M':sum=11;break;
case 'N':sum=20;break;
case 'O':sum=48;break;
case 'P':sum=29;break;
case 'Q':sum=38;break;
case 'R':sum=47;break;
case 'S':sum=56;break;
case 'T':sum=65;break;
case 'U':sum=74;break;
case 'V':sum=83;break;
case 'W':sum=21;break;
case 'X':sum=3;break;
case 'Y':sum=12;break;
case 'Z':sum=30;break;
}
temp=sum+
8*(id_num[1]-48)+
7*(id_num[2]-48)+
6*(id_num[3]-48)+
5*(id_num[4]-48)+
4*(id_num[5]-48)+
3*(id_num[6]-48)+
2*(id_num[7]-48)+
1*(id_num[8]-48)+
1*(id_num[9]-48);
if(temp%10==0)
{
printf("合法\n");
}
else
{
printf("不合法\n");
}
return 0;
}
沒有留言:
張貼留言