杭电acm2025

http://acm.hdu.edu.cn/showproblem.php?pid=2025

先求得最大的那个字符,然后一个一个对比,如果相等,就输出字符并输出(max),否则直接输出来就可以了

View Code
 1 #include<stdio.h>
 2 #include<string.h>
 3 int main()
 4 {
 5  int i,j,n;
 6  char s[100000],x;
 7  while(scanf("%s",s)!=EOF)
 8     {
 9      x=s[0];
10      for(i=1;s[i]!='\0';i++)
11        {
12         if(s[i]>x)
13           x=s[i];
14        }//求得最大字符
15      for(j=0;j<i;j++)
16        if(s[j]==x)
17          printf("%c(max)",s[j]);
18        else printf("%c",s[j]);//按要求输出
19      printf("\n");
20     }
21  return 0;
22 }
原文地址:https://www.cnblogs.com/huzhenbo113/p/2983265.html