题解 | #[NOIP2008]ISBN号码#
[NOIP2008]ISBN号码
http://www.nowcoder.com/practice/95712f695f27434b9703394c98b78ee5
#include<stdio.h>
int main()
{
char arr[13];
int i, j;
scanf("%s",arr);
int s = 0;
for(i=0, j=1; i<11; i++)
{
if(arr[i] != '-')
{
s += (arr[i]-'0')*j;
j++;
}
}
int m = s % 11;
if(m == arr[12]-'0' || (m == 10 && arr[12] == 'X'))
{
printf("Right\n");
}
else
{
if(m == 10)
{
for(i=0; i<12; i++)
{
printf("%c", arr[i]);
}
printf("X");
}
else{
for(i=0; i<12; i++)
{
printf("%c", arr[i]);
}
printf("%d", m);
}
}
}