zhangshudong @ 2023-05-24 23:59:17
P1055 [NOIP2008 普及组] ISBN 号码
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
char str[20];
cin >> str;
int len = strlen(str);
int sum = 0;
double remainder = 0;
sum = (str[0] - '0') * 1 + (str[2] - '0') * 2 + (str[3] - '0') * 3 + (str[4] - '0') * 4 + (str[6] - '0') * 5 + (str[7] - '0') * 6 + (str[8] - '0') * 7 + (str[9] - '0') * 8 + (str[10] - '0') * 9;
remainder = sum % 11;
int a = str[12]-'0';
if (remainder == a)
{
cout << "Right";
}
else
{
for (int i = 0; i <= 11; i++)
{
cout << str[i];
}
cout << remainder;
}
return 0;
}
by xiaoshumiao @ 2023-05-25 16:25:42
如果验证码是'X',你该怎么办呢?
by SimpleJony @ 2023-06-14 20:44:02
注意看题目,题目有余数等于10识别码为X的情况,要特判