这个题目有一点没有说清楚——题目中给的描述是最大字母,有歧义小写字母z和大写字母Z都算不算最大的呢?如果是按ASCII码表的值,当然是小写字母z最大。这里需要注意一下,题目中的大小依据的是ASCII表。
#include <cstdio>
#include <cctype>
/**
* 这个题不够严谨:没有明确给出怎么比较大写字母和小写字母的大小
* 同一个字母的大小写形式按常理理解是一样的还是按照ASCII码值来比较大小
*/
const int MAX_SIZE = 100 + 2;
char str[MAX_SIZE];
//#define YANGYUAN
int main()
{
#ifdef YANGYUAN
freopen("in.txt", "r", stdin);
#endif // YANGYUAN
while (fgets(str, MAX_SIZE, stdin))
{
int length = 1, max = str[0];
for (int i = 1; i < MAX_SIZE && str[i] != '\n' && str[i] != '\0'; ++i)
if (max < str[i])
max = str[i];
for (int i = 0; i < MAX_SIZE && str[i] != '\n' && str[i] != '\0'; ++i)
{
printf("%c", str[i]);
if (max == str[i])
printf("(max)");
}
printf("\n");
}
return 0;
}