Problem H: 零起点学算法103——查找最大元素

#include<stdio.h>
#include<string.h>
int main()
{
    char a[105];
    while(gets(a)!=NULL)
    {
        int k=a[0];
        for(int i=1;a[i]!='\0';i++)
        {
            if(a[i]>k){
                k=a[i];
            }
        }
        
        for(int i=0;a[i]!='\0';i++)
        {
            printf("%c",a[i]);
            if(k==a[i])
            {
                printf("(max)");
            }
        }
        printf("\n");
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/chenlong991223/p/9977225.html