解题思路:
注意事项:
参考代码:
#include<iostream> #include<string> using namespace std; int main() { string str; int jud = 0; while (cin >> str) { int j = 1; jud = 0; for (int i = 0; i < str.size() - 1; i++) { if (i == 0 || (i > 1 && i < 5) || (i > 5 && i < 11)) jud = jud + (j++) * (str[i] - '0'); } int temp = jud % 11; if (temp == 10) { char temp = 'X'; if (temp == str[str.size() - 1]) cout << "Right" << endl; else cout << str.substr(0, str.size() - 1) << temp << endl; } else { if (temp == str[str.size() - 1] - '0') cout << "Right" << endl; else cout << str.substr(0, str.size() - 1) << temp << endl; } } return 0; }
0.0分
0 人评分
C二级辅导-进制转换 (C语言代码)浏览:615 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:377 |
printf基础练习2 (C语言代码)浏览:644 |
DNA (C语言描述,蓝桥杯)浏览:1553 |
1642题解浏览:708 |
愚蠢的摄影师 (C++代码)浏览:932 |
DNA (C语言代码)浏览:390 |
2003年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:511 |
时间转换 (C语言代码)浏览:624 |
简单的a+b (C语言代码)浏览:628 |