hdu 2025

这题一开始想错了,以为是Z z最大,不分大小写,然后wa了

后来知道了是直接比较字符的ascii码大小,最大值初值是‘’和ss[0]都可以

先过一遍找到最大值,第二遍输出,是最大值附加输出

#include<bits/stdc++.h>

using namespace std;
int main()
{
    char ss[102];

    while(cin >> ss){
        int m = ss[0],len = strlen(ss);
        for(int i = 0;i < len;i++){
            if(ss[i] > m){
                m = ss[i];
            }
        }

        for(int i = 0;i < len;i++){
            printf("%c",ss[i]);
            if(ss[i] == m){
                printf("(max)");
            }
        }
        printf("
");
    }
    return 0;
}
原文地址:https://www.cnblogs.com/gudygudy/p/10489803.html