bak 2

https://www.cnblogs.com/Dageking/p/4029493.html

Have a nice day! :-) --来自Linda的祝福

char str[256];
    //scanf("%s", str);
    gets_s(str);
   // getws(str);
    int size = strlen(str);
    int countCh = 0;
    int countNum = 0;
    int countK = 0;
    int countOther = 0;

   
    for (int i = 0; i < size; i++)
    //while(1)
    {
        wchar_t ch = str[i];
       // wchar_t ch = getwchar();
        if ('\r' == ch || '\n' == ch) break;

        if (ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z') {
            countCh++;
         }
        else if (ch >= '0' && ch <= '9' )
        {
            countNum++;
        }
        else if (ch == ' ' )
        {
            countK++;
        }
        else if(!(ch <=127&&ch>0))
        {
            i+=2;
            countOther++;
        }
        else
        {
            countOther++;
        }
    
    }
    printf("%d %d %d %d\n", countCh, countNum, countK, countOther);

 

posted @ 2023-06-25 15:24  cnchengv  阅读(19)  评论(0)    收藏  举报