先用STL的*max_element()找出最大值,再用insert()插入即可 #include <iostream> #include <cstdlib> #include <cmath> #include <deque> #include <algorithm> #include <numeric> #include <iterator> #include <sstream> #include <iomanip> #include <vector> #include <string.h> #include <string> using namespace std; int main() { string str; while(cin>>str) { char ch=*max_element(str.begin(),str.end()); int temp=str.size(); for(int i=0;i<temp;i++) { if(str[i]==ch) { str.insert(i+1,"(max)"); i+=5; temp+=5; } } cout<<str<<endl; } return 0; }
解题思路:
注意事项:
参考代码:
0.0分
2 人评分
C语言训练-计算t=1+1/2+1/3+...+1/n (C语言代码)浏览:510 |
K-进制数 (C++代码)浏览:875 |
数列 (C++代码)浏览:672 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:722 |
C语言程序设计教程(第三版)课后习题8.6 (C语言代码)浏览:549 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:909 |
简单的a+b (C语言代码)浏览:547 |
C语言程序设计教程(第三版)课后习题6.10 (C语言代码)浏览:886 |
C语言程序设计教程(第三版)课后习题6.6 (C语言代码)浏览:353 |
【计算直线的交点数】 (C语言代码)浏览:1460 |