题目:
程序:
#include
#include
using namespace std;
ifstream fin ("isbn.in");
ofstream fout ("isbn.out");
string yuan;
int main ()
{int i,len,temp,sum;
fin>>yuan;
sum=0;
temp=1;
len=yuan.size();
for(i=0;i
{sum+=(yuan[i]-'0')*temp;
temp++;
}
sum%=11;
if(yuan[len-1]-'0'==sum)
fout<<"Right"<
if(sum==10&&yuan[len-1]=='X')
fout<<"Right"<
{for(i=0;i
fout<<'X'<
fout<
return 0;
}
哦,ISBN?
08年普及组的吧!
code:
#include
#include
int main()
{
long i=0,j=0,k=0,t,m;
char c[200],ch;
scanf("%s",c);
for(i = 0;i < strlen(c)-1;i ++)
{
if(c[i]!= '-')
{
j ++;
k += j * (c[i] - 48 );
}
}
if(c[i] == 'X') t = 10;
else t = c[i] - 48;
if(k % 11 == t )
{
printf("Right");
return 0;
}
for(j = 0;j < strlen(c)-1;j ++) printf("%c",c[j]);
if(k % 11 != 10)
printf("%c",k%11+48);
else printf("X");
return 0;
}
在VIJOS上过了的~~~~~~