A string of English characters (excluding spaces and other characters), count the number of each character, and output letters a

xiaoxiao2021-03-06  73

#include

#include

#include

int main ()

{

INT count [52];

INT I;

Char * pstr = (char *) malloc (sizeof (char *) * 256);

For (i = 0; i <52; i )

COUNT [I] = 0;

MEMSET (PSTR, '/ 0', 256);

Scanf ("% s", PSTR);

While (* pstr! = '/ 0')

{

Printf ("% c", * pstr);

IF ('A' <* pstr && * pstr <'z')

Count [* pstr-65] ;

IF ('A' <* pstr && * pstr <'z')

Count [* PSTR-97 26] ;

PSTR ;

}

For (i = 0; i <26; i )

Printf ("% C:% D / N", i 65, count [i]);

For (i = 26; i <26 26; i )

Printf ("% C:% D / N", I-26 97, COUNT [I]);

System ("pause");

Return 0;

}

转载请注明原文地址:https://www.9cbs.com/read-93443.html

New Post(0)