为什么做出来只有70分。。。
查看原帖
为什么做出来只有70分。。。
676809
cuijh007楼主2022/3/1 19:48
#include<iostream>
#include<string>
using namespace std;


int main () {
	string str;
	char c;
	int sum=0, i=1;
	cin>>str;
//	getline(cin, str);
	for(string::iterator it=str.begin(); it!=str.end()-1; it++) {
		
		if(*it>47 && *it<58) {
			sum += (*it-'0') * i++;
		}
		
	}
//	cout<<str;
	if(sum%11 == 10) c = 'X';
	else c = sum%11 + '0';

	if(c == *(str.end()-1)) {
		cout<<"Rigth";
	} else {
		*(str.end()-1) = c;
		cout<<str;
	}

	
	return 0;
}
2022/3/1 19:48
加载中...