题解 | #[NOIP2008]ISBN号码#
[NOIP2008]ISBN号码
http://www.nowcoder.com/practice/95712f695f27434b9703394c98b78ee5
int main()
{
char chs[13] = "";
int i = 0;
scanf("%s", chs);
int remainder = 0;
int ret = 0; //求和
int j = 0; //之前用的i,但是会因为continue跳过1和5
for(i = 0, j = 1; i < 11; i++)
{
if(i == 1 || i == 5)
{
continue;
}
else
{
ret += ((chs[i] - '0') * (j++));
}
}
remainder = ret % 11; //remainder,余数
if(remainder == 10)
{
if(chs[12] == 'X')
{
printf("Right");
}
else
{
chs[12] = 'X';
printf("%s",chs);
}
}
else
{
if(remainder == chs[12] - '0')
{
printf("Right");
}
else
{
chs[12] = remainder + '0';
printf("%s",chs);
}
}
return 0;
}