【算法竞赛宝典】读文章

【算法竞赛宝典】读文章

题目描述


代码展示

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;
}
相关推荐
惆怅客1237 小时前
在 vscode 中断点调试 ROS2 C++ 的办法
c++·vscode·调试·ros 2
进击的小头7 小时前
01_嵌入式C与控制理论入门:从原理到MCU实战落地
c语言·单片机·算法
what_20187 小时前
list 对象里面 嵌套list对象,对象的属性 有浮点数,list<浮点数> 对list对象求均值
算法·均值算法
眠りたいです7 小时前
Docker:镜像的运行实体-Docker Container
java·运维·c++·docker·容器·eureka
wanghowie7 小时前
01.09 Java基础篇|算法与数据结构实战
java·数据结构·算法
ComputerInBook7 小时前
C++ 标准提供的 thread (线程)之 join() 函数示例(windows平台)
c++·线程·join函数
快乐的划水a7 小时前
嵌入式时间测量方法总结
c++·stm32·单片机
郝学胜-神的一滴7 小时前
GLSL语法详解:从入门到实战
c++·算法·图形渲染
qq_463408427 小时前
React Native跨平台技术在开源鸿蒙中使用内置的`fetch` API或者第三方库如`axHarmony`来处理网络通信HTTP请求
javascript·算法·react native·react.js·http·开源·harmonyos
蒙奇D索大7 小时前
【数据结构】考研408 | 散列查找性能剖析:装填因子、冲突策略与优化全攻略
数据结构·考研·算法·哈希算法·改行学it