键盘输入10个字符放入数组中,输出ASCII码值最大的元素、它的ASCII码值和它所在的下标?

如题所述

#include <stdio.h>

#include<string.h>

int  main()

{  char str[20],max;

int x=0;

     gets(str);

    max=str[0];

    for(int i=0;i<strlen(str);i++)

    if(str[i]>max)

    {

    max=str[i];//记录最大值 

    x=i;//记录下标 

}

printf("max=%c \nmax address=%d \nASCII=%d",max,x,max);

    return 0;

}

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