C语言 用字符数组编程实现找出字符串中最大的那个字符元素,并输出该字符及其对应的ASCII码值

用字符数组编程实现找出字符串中最大的那个字符元素,并输出该字符及其对应的ASCII码值。假设字符数组能够存放最大字符个数为80。
**输入提示信息:"Input a string:\n"
**输入数据格式:用gets()输入字符串
**输出提示信息和格式:"The largest character is \'%c\'.The ASCII is %d.\n"
注:(1)不能使用指针、结构体、共用体、文件、goto、枚举类型进行编程。
(2)用纯C语言编程,所有变量必须在第一条可执行语句前定义。

C语言程序:

#include <stdio.h>
#include <string.h>

#define MAX 80

void main()
{
char arr[MAX + 1];
char max;
int len;
int i;

printf("Input a string:\n");
gets(arr);

max = '\0';
len = strlen(arr);
for(i=0; i<len; i++)
{
if(arr[i] > max)
{
max = arr[i];
}
}

printf("The largest character is \'%c\'.The ASCII is %d.\n", max, max);
}

 è¿è¡Œæµ‹è¯•ï¼š

温馨提示:答案为网友推荐,仅供参考