代码
#include <iostream>
using namespace std;
int main() {
string s;
while(getline(cin, s)){
char max = s.at(0);
for(int i=1; i<s.length(); i++){
if(s.at(i)>max){
max = s.at(i);
}
}
for(int i=0; i<s.length(); i++){
if(s.at(i)==max){
cout<<s.at(i)<<"(max)";
}
else{
cout<<s.at(i);
}
}
cout<<endl;
}
return 0;
}
注解
1、遍历一遍找最大值。
2、再遍历一遍,找到最大值的元素,其后加上(max)