1.代码如下:
#include<stdio.h>
#define N 5
int main(){
char arr[N];
printf("请输入5个字符: ");
for (int i = 0; i < N; i++)
arr[i] = getchar();
int max = 0;
int index;
for (int i = 0; i < N; i++){
if (max < arr[i]){
max = arr[i];
index = i;
}
}
printf("\n最大的字符是 %c-%d", arr[index], arr[index]);
getchar();
getchar();
return 0;
}
2.运行结果如下:

希望对你有帮助~