zoukankan      html  css  js  c++  java
  • 10.8输入一行文字,找出其中大写字母、小写字母、空格、数字及其他字符各有多少?

    10.8输入一行文字,找出其中大写字母、小写字母、空格、数字及其他字符各有多少?

    #include <stdio.h>
    
    int main(){
        char * p,str[50];
        int upper=0, lower=0,digit=0,space=0,other=0;
        p=str;
        printf("请输入一行字符,以回车键结束.
    ");
        gets(str);
        while((*p) != ''){
            if(*p>='A' && *p<='Z') ++upper;
            else if(*p>='a' && *p<='z') ++lower;
            else if(*p>='0' && *p<='9') ++digit;
            else if(*p==' ') ++space;
                    else ++other;
            p++;
        }
        printf("the number of upper is %d
    ",upper);
        printf("the number of lower is %d
    ",lower);
        printf("the number of digit is %d
    ",digit);
        printf("the number of space is %d
    ",space);
        printf("the number of other is %d
    ",other);
        return 0;
    }

    结果:

  • 相关阅读:
    数据可视化
    tkinter学习04
    小练习-----银行提款机系统
    python___docx模块
    Django【进阶篇 】
    Django之Cookie/session/防止XSS攻击
    tkinter学习03
    tkinter学习02
    AJAX
    tkinter学习01
  • 原文地址:https://www.cnblogs.com/Allen-win/p/7272361.html
Copyright © 2011-2022 走看看