【算法竞赛宝典】读文章

【算法竞赛宝典】读文章

题目描述


代码展示

cpp 复制代码
//读文章 
#include <iostream>
#include <string.h>

using namespace std;

int main() {
    int i, j, upp, low, dig, spa, oth;
    char text[3][80];
    upp = low = dig = spa = oth = 0;
    for (i = 0; i < 3; i++) {
        gets(text[i]);
        for (j = 0; j < 80; j++) {
            if (text[i][j] >= 'A' && text[i][j] <= 'Z')
                upp++;
            else if (text[i][j] >= 'a' && text[i][j] <= 'z')
                low++;
            else if (text[i][j] >= '0' && text[i][j] <= '9')
                dig++;
            else if (text[i][j] == ' ')
                spa++;
            else
                oth++;
        }
    }

    cout << upp << endl;
    cout << low << endl;
    cout << dig << endl;
    cout << spa << endl;
    cout << oth << endl;
    return 0;
}
相关推荐
handler012 分钟前
速通蓝桥杯省一:二分算法
c语言·开发语言·c++·笔记·算法·职场和发展·蓝桥杯
炽烈小老头2 分钟前
【 每天学习一点算法 2026/05/08】最小覆盖子串
学习·算法
汉克老师24 分钟前
GESP5级C++考试语法知识(十六、分治算法(三))
c++·算法·分治算法·汉诺塔·逆序对·gesp5级·gesp五级
V搜xhliang024626 分钟前
OpenClaw进阶完全教程
运维·人工智能·算法·microsoft·自动化
hele_two28 分钟前
SDL2设置透明度
c++·图形渲染
小杰31229 分钟前
网络框架源码阅读技巧
服务器·网络·c++·reactor·zlmediakit·zltoolkit
叼烟扛炮34 分钟前
C++ 知识点12 构造函数
开发语言·c++·算法·构造函数
满天星83035771 小时前
定长内存池ObjectPool
数据结构·c++·算法·链表
叼烟扛炮1 小时前
C++第八讲:string 类
开发语言·c++·算法·string
MOONICK1 小时前
bit7z压缩与解压
c++