Home > Back-end >  Statistics of the string all the English letters of the number of abnormal # include <iostream>
Statistics of the string all the English letters of the number of abnormal # include <iostream>

Time:04-17

CodePudding user response:

# include & lt; Iostream>
# include & lt; Cstring>
using namespace std;
Int main ()
{
Int I, j, k;
Int the lett [26]={0};
Char s [60];
cout<" The input string: "& lt; gets(s);//enter
cout<" The number of letters statistical results as follows: "& lt; for (i=0; i<60; I++)
{if (s [I] & gt;='a' & amp; & S [I] <='z')
Lett [s [I] - 'a'] + +;
Else if (s [I] & gt;='A' & amp; & S [I] <='Z')
Lett [s [I] - 'A'] + +;
coutcout}
for(k=0; K<26. K++)
{
Char d='A' + k;
coutIf ((k + 1) % 10==0)
cout}
return 0;

CodePudding user response:

Reference:
 # include & lt; Iostream> 
# include & lt; Cstring>
using namespace std;
Int main ()
{
Int I, j, k;
Int lett_l [26]={0};//lowercase
Int lett_c [26]={0};//caps
Char s [60];
cout<" The input string: "& lt; Cin> s;//gets (s);//enter
J=strlen (s);//the length of the string
cout<" The number of letters statistical results as follows: "& lt; for (i=0; i{
If (s [I] & gt;='a' & amp; & S [I] <='z')
Lett_l [s [I] - 'a'] + +;
The else
If (s [I] & gt;='A' & amp; & S [I] <='Z')
Lett_c [s [I] - 'A'] + +;
//cout//cout}
for(k=0; K<26. K++)
{
Char d='A' + k;
Char l='a' + k;
If (lett_c [k]!=0 | | lett_l [k]!=0) {
cout//if ((k + 1) % 10==0)
//cout}
}

return 0;
}

CodePudding user response:

That excuse me what is the program mistakes

CodePudding user response:

reference m0_56926947 reply: 3/f
that excuse me the program is what an error
uppercase, lowercase letters, in the same array, overlapping, capital 'A' statistical time, met the lower case 'A' statistics once again, the final output is capitalized + numerical lowercase word, just can't tell which is which, and the cycles when such as statistics, should be the actual length of the input string, the code is 60 array length, there are other problems, see the 2 # floor code comments,
  • Related