输入的是字符,需要转为数字相乘,另外for中有i++,循环体中就不需要了
//#include "stdafx.h"
#include "stdio.h"
#include "string.h"
int main(int argc, char* argv[])
{
char id[18];
char mw[12] = { "10X98765432" }, c;
int xs[18] = { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 };
int i, sum = 0, ys, k, cj;
for (k = 0; k <= 16; k++)
{
scanf("%c", &id[k]);
}
for (i = 0; i <= 16; i++)
{
cj = (id[i]-'0') * xs[i];/////////
sum = sum + cj;
//i++;////////
}
ys = sum % 11;
c = mw[ys];
printf("%c", c);
return 0;
}