題目描述 對于輸入的每個字符串,查找其中的最大字母,在該字母后面插入字符串“(max)”。 Input 輸入數據包括多個測試實例,每個實例由一行長度不超過100的字符串組成,字符串僅由大小寫字母構成。 Output 對于每個測試實例輸出一行字符串,輸出的結果是插入字符串“(max)”后的結果,如果存在多個最大的字母,就在每一個最大字母后面都插入”(max)”。 #include #include #include #include #include using namespace std; int main() { char max,a[105]; while(scanf(“%s”,a)!=EOF) { max=’a’; int len=strlen(a); for(int i=0;i< len;i++) {if(max< a[i]) max=a[i]; } for(int i=0;i< len;i++) {cout<< a[i]; if(a[i]==max) cout<<”(max)”; }cout<<”/n”; }return 0;
} </php>
新聞熱點
疑難解答