作者在 2020-04-23 22:06:50 发布以下内容
#include <stdio.h>
int main(void)
{
char id[17];
int idx[17]={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
char last[11]={'1','0','X','9','8','7','6','5','4','3','2'};
int sum=0,i;
printf("Please input ID:");
for (int i=0;i<17;i++)
{
scanf("%c",&id[i]);
//printf("%c",id[i]);
}
for (int i=0;i<17;i++)
{
sum+=(id[i]-'0')*idx[i];
}
i=sum%11;
//printf("sum=%d,i=%d",sum,i);
printf("\n\n\nThe last is:%c",last[i]);
return 0;
}
int main(void)
{
char id[17];
int idx[17]={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
char last[11]={'1','0','X','9','8','7','6','5','4','3','2'};
int sum=0,i;
printf("Please input ID:");
for (int i=0;i<17;i++)
{
scanf("%c",&id[i]);
//printf("%c",id[i]);
}
for (int i=0;i<17;i++)
{
sum+=(id[i]-'0')*idx[i];
}
i=sum%11;
//printf("sum=%d,i=%d",sum,i);
printf("\n\n\nThe last is:%c",last[i]);
return 0;
}