编程实现找出字符串中最大字符元素并输出该元素及其对应的ASCII值.
****要求输入提示信息为:
"Input a string:\n"
****输出格式要求为:
"The largest character of "%s" is '%c' ,The ASCII is %d."
程序运行示例:
Input a string:↙
I am a student.
The largest character of "I am a student." is 'u' ,The ASCII is 117.↙
#include<stdio.h>
#include<string.h>
#define N 100
int main()
{
char a[N];
gets(a);
char temp=a[0];
int i;
for(i=0;i!='\0';i++)
{
if(a[i]>temp)
{
temp=a[i];
}
}
printf("The largest character of \"%s\" is \'%c\' ,The ASCII is %d.",a,a[i],a[i]);
return 0;
}