ccf 201312-2 ISBN号码
1 #include<iostream> 2 #include<cstring> 3 using namespace std; 4 char num[11]; 5 int main() 6 { 7 char c; 8 int temp = 1; 9 while(temp<11) 10 { 11 c = getchar(); 12 while(c == '-') c = getchar(); 13 num[temp++] = c; 14 } 15 int ans = 0; 16 for(int i=1;i<=9;i++) 17 { 18 ans += i*(num[i]-'0'); 19 } 20 ans = ans%11; 21 bool flag = false; 22 if(num[10] == 'X') 23 { 24 if(ans==10) flag = true; 25 }else{ 26 if(ans == num[10]-'0') flag = true; 27 } 28 29 if(flag) cout<<"Right"<<endl; 30 else{ 31 cout<<num[1]<<"-"<<num[2]<<num[3]<<num[4]; 32 cout<<"-"<<num[5]<<num[6]<<num[7]<<num[8]<<num[9]<<"-"; 33 if(ans == 10) cout<<"X"<<endl; 34 else cout<<ans<<endl; 35 } 36 37 return 0; 38 }