【算法竞赛宝典】读文章

【算法竞赛宝典】读文章

题目描述


代码展示

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;
}
相关推荐
mit6.8242 分钟前
中位数贪心|前缀和_距离和ret=l+r_1
算法
一匹电信狗3 分钟前
【LeetCode】栈和队列进阶题目
c++·算法·leetcode·职场和发展·stl·栈和队列
Bin二叉4 分钟前
南京大学cpp复习——第二部分(继承)
开发语言·c++·笔记·学习
机器学习之心5 分钟前
198种组合算法+优化TCN时间卷积神经网络+SHAP分析+新数据预测+多输出!深度学习可解释分析,强烈安利,粉丝必备!
深度学习·算法·shap分析·tcn时间卷积神经网络
代码游侠6 分钟前
数据结构——线性表
linux·c语言·数据结构·学习·算法
吃着火锅x唱着歌8 分钟前
LeetCode 3371.识别数组中的最大异常值
数据结构·算法·leetcode
元亓亓亓11 分钟前
LeetCode热题100--74. 搜索二维矩阵--中等
算法·leetcode·矩阵
lingggggaaaa21 分钟前
免杀对抗——C2远控篇&PowerShell&C#&对抗AV-EDR&停用AMSI接口&阻断ETW跟踪&调用
c语言·开发语言·c++·学习·安全·c#·免杀对抗
zzzsde22 分钟前
【C++】异常:概念及使用
开发语言·c++·算法
繁星星繁22 分钟前
CMake快速上手
c语言·c++·编辑器·学习方法·visual studio code