大佬们,看一下这道题哪错了,为啥只有50分呢?
查看原帖
大佬们,看一下这道题哪错了,为啥只有50分呢?
895310
zhangshudong楼主2023/5/24 23:59

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;
}
2023/5/24 23:59
加载中...