hdu 2025 查找最大元素

来源:互联网 发布:送父亲的礼物 知乎 编辑:程序博客网 时间:2024/05/17 06:58
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2025

题目大意:在一串字符的最大元素后面加(max)的标识,如果都是最大元素就在每一个后面全部加上 (max)!

 1 #include <stdio.h> 2 #include <string.h> 3 int main () 4 { 5     char ch[100],t; 6     int len,i; 7     while (gets(ch)) 8     { 9         len=strlen(ch);10         t='0';11         for (i=0; i<len; i++)12             if (ch[i]>t)13                 t=ch[i];14         for (i=0; i<len; i++)15             if (ch[i]==t)16                 printf ("%c(max)",ch[i]);17             else18                 printf ("%c",ch[i]);19         printf ("\n");20     }21     return 0;22 }

 

0 0
原创粉丝点击