真简单

牛浩宇  •  22天前


include

include

using namespace std; int main(int r, char **argv) {

int a[13] = {0}, nhy = 0, js = 0;
string s = " ";
cin >> s;

for (int i = 0; i < s.length(); ++i) {
	if (s[i] == '-')
		continue;
	a[js] = s[i] - '0';
	js++;
	if (s[i] == 'X')
		a[9] = 10;
}

for (int i = 0; i < 10; i++) {
	if (i != 9) {
		nhy = nhy + a[i] * (i + 1);
	}
}
nhy = nhy % 11;

if (nhy == a[9]) {
	cout << "Right";
} else {
	for (int j = 0; j < 12; j++) {
		cout << s[j];
	}
	if (nhy == 10) {
		cout << 'X';
		return 0;
	}
	cout << nhy;
}
return 0;

}


评论:

请先登录,才能进行评论