【算法竞赛宝典】读文章

【算法竞赛宝典】读文章

题目描述


代码展示

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;
}
相关推荐
科大饭桶1 小时前
数据结构自学Day5--链表知识总结
数据结构·算法·leetcode·链表·c
mit6.8241 小时前
[Meetily后端框架] Whisper转录服务器 | 后端服务管理脚本
c++·人工智能·后端·python
L_autinue_Star3 小时前
手写vector容器:C++模板实战指南(从0到1掌握泛型编程)
java·c语言·开发语言·c++·学习·stl
我爱C编程3 小时前
基于Qlearning强化学习的1DoF机械臂运动控制系统matlab仿真
算法
chao_7893 小时前
CSS表达式——下篇【selenium】
css·python·selenium·算法
chao_7893 小时前
Selenium 自动化实战技巧【selenium】
自动化测试·selenium·算法·自动化
YuTaoShao3 小时前
【LeetCode 热题 100】24. 两两交换链表中的节点——(解法一)迭代+哨兵
java·算法·leetcode·链表
怀旧,3 小时前
【数据结构】8. 二叉树
c语言·数据结构·算法
泛舟起晶浪3 小时前
相对成功与相对失败--dp
算法·动态规划·图论
地平线开发者4 小时前
地平线走进武汉理工,共建智能驾驶繁荣生态
算法·自动驾驶