• 有三行文字,每行最多80个字符,求其中大写字母,小写字母,数字,空格和其他


    #include<stdio.h>
    int main() {
        char text[3][20];//定义三行,每行最多不超过20个字符的二位数组
        char c;
        int i,j;
    
        int upCase,lowCase,num,space,others;
        upCase=lowCase=num=space=others=0;
        for(i=0;i<3;i++){
            gets(text[i]);
            for(j=0;j<20&&((c=text[i][j])!='');j++){
                if(c>='A'&&c<='Z'){
                    upCase++;
                }else if(c>='a'&&c<='z'){
                    lowCase++;
                }else if(c>='0'&&c<='9'){
                    num++;
                }else if(c==' '){
                    space++;
                }else {
                    others++;
                }
            }
        }
        //upcase 大写字母 lowcase 小写字母 num 数字 space 空格 others 其他 
        printf("upCase=%d,lowCase=%d,num=%d,space=%d,others=%d",upCase,lowCase,num,space,others);
    
        return 0;
    }
    
  • 相关阅读:
    【关键字】
    【选择结构语句:switch】
    【数据类型】
    【接口】
    【抽象类和接口的区别】
    【访问权限】
    【内部类】
    【方法】
    【this 关键字】
    【Static】
  • 原文地址:https://www.cnblogs.com/ycycn/p/13788377.html
Copyright © 2020-2023  润新知