Home > Back-end >  Please the great god, can't run
Please the great god, can't run

Time:10-04

//2, there is an article, a total of 3 lines, each line has 80 characters,
//requirements, respectively, the statistics of English uppercase letters, lowercase letters,
//the number of Numbers and other characters,
#include
Int main ()
{
Char text [3] [80].
Int I, j, da=0, xi=0, sh=0, oth=0;
//the capital letters: da lowercase letters: xi
//number: sh other characters: oth
Printf (" input three lines: ");
For (I=0; I<3; I++)
{
For (j=0, j<80; J++)
The scanf (" % d % d ", & amp; & Text [I] [j]);//input line 3 80 - word article
{
If (text [I] [j] & gt;='A' & amp; & Text [I] [j] <='Z')//judgment
Da++;
Else if (text [I] [j] & gt;='a' & amp; & Text [I] [j] <='z')
Xi++;
Else if (text [I] [j] & gt;='0' & amp; & Text [I] [j] <='9')
Sh++;
The else
Oth++;
}
}
Printf (" capital letters: % d \ n ", da);//output
Printf (" lowercase letters: % d \ n ", xi);
Printf (" digital: % d \ n ", sh);
Printf (" symbol: % d \ n ", oth);
return 0;
}

CodePudding user response:

 # include 
#include

Int main ()
{
If # 1

Int upper_cnt lower_cnt, digit_cnt other_cnt;
Int I, j;
Char text [3] [128].

Upper_cnt=lower_cnt=digit_cnt=other_cnt=0;

for (i=0; I & lt; 3; I++) {
The scanf (" % s ", the text [I]);
j=0;
While (text [I] [j]) {
If (isdigit (text [I] [j]))
Digit_cnt + +;
Else if (isupper (text [I] [j]))
Upper_cnt + +;
Else if (islower (text [I] [j]))
Lower_cnt + +;
The else
Other_cnt + +;
j++;
}
}

Printf (" capital letters: % d \ n ", upper_cnt);//output
Printf (" lowercase letters: % d \ n ", lower_cnt);
Printf (" digital: % d \ n ", digit_cnt);
Printf (" symbol: % d \ n ", other_cnt);
# the else

Char text [3] [80].
Int I, j, da=0, xi=0, sh=0, oth=0;

//the capital letters: da lowercase letters: xi
//number: sh other characters: oth
Printf (" input three lines: ");
For (I=0; I<3; I++)
{
For (j=0, j<80; J++)
The scanf (" % d % d ", & amp; & Text [I] [j]);//input line 3 80 - word article
{
If (text [I] [j] & gt;='A' & amp; & Text [I] [j] <='Z')//judgment
Da++;
Else if (text [I] [j] & gt;='a' & amp; & Text [I] [j] <='z')
Xi++;
Else if (text [I] [j] & gt;='0' & amp; & Text [I] [j] <='9')
Sh++;
The else
Oth++;
}
}
Printf (" capital letters: % d \ n ", da);//output
Printf (" lowercase letters: % d \ n ", xi);
Printf (" digital: % d \ n ", sh);
Printf (" symbol: % d \ n ", oth);

# endif

return 0;
}


For your reference ~

The original poster with the scanf % d is to input characters?
  • Related