We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#include<iostream> #include<cmath> #include<algorithm> using namespace std; int main() { string s; while (cin >> s) { int count = 0; // 统计数字的个数 int sOldSize = s.size(); for (int i = 0; i < s.size(); i++) { if (s[i] >= '0' && s[i] <= '9') { count++; } } // 扩充字符串s的大小,也就是每个空格替换成"number"之后的大小 s.resize(s.size() + count * 5); int sNewSize = s.size(); // 从后先前将空格替换为"number" for (int i = sNewSize - 1, j = sOldSize - 1; j < i; i--, j--) { if (s[j] > '9' || s[j] < '0') { s[i] = s[j]; } else { s[i] = 'r'; s[i - 1] = 'e'; s[i - 2] = 'b'; s[i - 3] = 'm'; s[i - 4] = 'u'; s[i - 5] = 'n'; i -= 5; } } cout << s << endl; } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: