解题思路:
注意事项:
参考代码:
#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语言程序设计教程(第三版)课后习题7.1 (C语言代码)浏览:518 |
DNA (C语言描述,数据结构)浏览:862 |
A+B for Input-Output Practice (V) (C语言代码)浏览:470 |
JAM计数法 (C语言代码)浏览:671 |
简单的a+b (C语言代码)浏览:587 |
C二级辅导-温度转换 (C语言代码)浏览:550 |
孤独的骑士 (C语言代码)浏览:1372 |
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)浏览:393 |
C语言程序设计教程(第三版)课后习题8.2 (C++代码)浏览:661 |
C语言程序设计教程(第三版)课后习题10.7 (C语言代码)浏览:4369 |