2019.3.22HDOJ-2025查找最大元素,AC率52.39%(43258/82566)

版权声明:那啥,咱一个萌新写的东西没啥价值。但是也要打个招呼吧…… https://blog.csdn.net/Miaplacidus/article/details/88753334

熄灯后水了一题,感觉好久没AC了啊

题目

Problem-2025
Problem Description
对于输入的每个字符串,查找其中的最大字母,在该字母后面插入字符串“(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)

AC的代码

#include<stdio.h>
int main(void)
{
	char arr[105],max;
	while(scanf("%s",arr)!=EOF){
		int i;
		max=arr[0];
		for(i=0;arr[i]!='\0';i++){
			max=(max<arr[i])?arr[i]:max;
		}
		for(i=0;arr[i]!='\0';i++){
			putchar(arr[i]);
			if(arr[i]==max)
				printf("(max)");
		}
		printf("\n");
	}
	return 0;
}
Run ID Submit Time Judge Status Pro.ID Exe.Time Exe.Memory Code Len. Language Author
28668003 2019-03-22 23:13:12 Accepted 2025 15MS 1696K 315 B C Overstars

2019年3月22日23点16分

猜你喜欢

转载自blog.csdn.net/Miaplacidus/article/details/88753334