查找最大元素
#include <iostream> #include <string> #include <cstring> using namespace std; int main() { string s; while(cin >> s) { char smax = s[0]; int len = s.length(); for(int i = 1; i < len; ++ i) { if(s[i] > smax) { smax = s[i]; } } for(int i = 0; i < len; ++ i) { cout << s[i]; if(s[i] == smax) { cout << "(max)"; } } cout << endl; } return 0; }