Problem F: 零起點學算法101——統計字母數字等個數


#include<stdio.h>
#include<string.h>
int main(){
    char str[105];
    while(gets(str)!=NULL){
        int a=0,b=0,c=0,d=0;
        for(int i=0;str[i]!='\0';i++){
            if((str[i]>='a'&&str[i]<='z')||(str[i]>='A'&&str[i]<='Z')){
                a++;
            }
            else if(str[i]>='0'&&str[i]<='9'){
                b++;
            }
            else if(str[i]==' '){
                c++;
            }
            else{
                d++;
            }
        }
        printf("%d %d %d %d\n",a,b,c,d);
    }
    return 0;
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM