#include
#include
#include
# define N 300
Int main ()
{
Int n={0} [n], Max, I;
Char a [N], ch, j;
While (gets) (a)!=NULL)
{
If (islower (a [I])!=0)
{
For (j='A'; J<='Z'; J++)
for(i=0; I
N [j] + +;
}
Else if (isupper (a [I])!=0)
{
For (j='a'; J<='z'; J++)
for(i=0; I
N [j] + +;
}
Ch='A', Max=n (ch);
For (j='A'; J<='z'; J++)
If (isalpha (j)!=0)
{
If (n [j] & gt; Max)
Max=n [j], ch=j;
Else if (n==max& [j]. & J
}
Printf (" % d % c \ n ", ch, Max).
}
return 0;
}
Input:
I am a student
A good programming problem
The ABCD ABCD ABCD ABCD
Output:
A 2
O 4
A 2
However:
A 2
A 2
A 2
CodePudding user response:
Where you function islower ()CodePudding user response:
# include
#include
#include
//# define N 300
# define N 300
Int main ()
{
//int n={0} [n], Max, I, j;
//char a [N], ch.//, j;
Int n [52]={0}, I;
Int ch, Max;
Char a, [N].
While (the fgets (a, N, stdin)!=NULL)
{
i=0;
//puts (a);
While (a [I]) {
//putchar (a [I]);
If (isupper (a [I]))
N [a [I] - 'a'] + +;
If (islower (a [I]))
N [a [I] - 'a' + 26] + +;
i++;
}
Max=n [0];
For (I=1; i <52. I++)
If (Max & lt; N [I]) {
Max=n [I];
}
Printf (" Max=% d \ n ", Max).
For (I=0; i <52. I++)
If (Max==n [I]) {
If (I & gt;=26)
Ch='a' + (I - 26);
The else
Ch='A';
break;
}
Printf (" % d % c \ n ", ch, Max).
Memset (n, 0, sizeof (n));
# if 0
If (isalpha (j)!=0)
If (islower (a [I])!=0)
{
For (j='A'; J<='Z'; J++)
for(i=0; IIf (a==j [I])
N [j] + +;
}
Else if (isupper (a [I])!=0)
{
For (j='a'; J<='z'; J++)
for(i=0; IIf (a==j [I])
N [j] + +;
}
Ch='A', Max=n (ch);
For (j='A'; J<='z'; J++)
If (isalpha (j)!=0)
{
If (n [j] & gt; Max)
Max=n [j], ch=j;
Else if (n==max& [j]. & JMax=n [j], ch=j;
}
Printf (" % d % c \ n ", ch, Max).
# endif
}
return 0;
}
For your reference ~
CodePudding user response: