求助4,5,6,7,9红
查看原帖
求助4,5,6,7,9红
891562
Hayward楼主2022/11/30 09:54
#include<iostream>
#include<string>
using namespace std;
int main()
{
	char c[13]{};
	int x = 0;//
	int temp = 0;
	for (int i = 0; i < 13; i++)
	{
		cin >> c[i];
		if (c[i]=='X')
		{
			c[i] = 10;
		}
	}
	for (int i = 0; i < 12; i++)
	{
		if (c[i] != '-')
		{
			x++;
			temp+= (c[i] - '0') * x;//'0'就是48,char类型运算时会变更为阿斯克码
			//cout << temp << endl;
		}
	}
	int a=c[12]-48;
	if (temp % 11 == a)
	{
		cout << "Right";
		return 0;
	}
	else
	{
		int b = temp % 11;
		//c[12] = temp % 11;
		for (int i = 0; i < 12; i++)
		{
			cout << c[i];
		}
		cout << b;
	}
}
2022/11/30 09:54
加载中...