50分,45689都错求助
查看原帖
50分,45689都错求助
443754
Sender_T楼主2021/4/3 22:29

rt,以下是代码

#include<bits/stdc++.h>
using namespace std;
int temp=0,cnt=1;
bool fh(char a[]){
	if(strlen(a)!=13){
		return false;
	}else{
		for(int i=0;i<=11;i++){
			if(a[i]!='-'){
				temp=temp+(a[i]-'0')*cnt;
				cnt++;
			}
		}
		if(temp%11==(a[12]-'0')){
			return true;
		} else if(temp%11==10 &&a[12]=='X'){
		    return true;	
		}else{
			a[12]=temp%11%10+'0';
			return false;
		}
		
	}
}
char a[14];
int main(){
	gets(a);
	if(fh(a)) cout<<"Right";
	else cout<<a;
	return 0;
} 
2021/4/3 22:29
加载中...