對於輸入的每個字符串,查找其中的最大字母,在該字母后面插入字符串“(max)”。
Input
輸入數據包括多個測試實例,每個實例由一行長度不超過100的字符串組成,字符串僅由大小寫字母構成。
Output
對於每個測試實例輸出一行字符串,輸出的結果是插入字符串“(max)”後的結果,如果存在多個最大的字母,就在每一個最大字母后面都插入"(max)"。
Sample Input
abcdefgfedcba
xxxxx
Sample Output
abcdefg(max)fedcba
x(max)x(max)x(max)x(max)x(max)
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main()
{
int n,i;
char a[120];
char x;
while(gets(a)){
x='A';
for(i=0;i<strlen(a);i++){
if(a[i]>x)x=a[i];
}
for(i=0;i<strlen(a);i++){
if(a[i]==x)printf("%c(max)",a[i]);
else printf("%c",a[i]);
}
printf("\n");
}
return 0;
}