【算法竞赛宝典】读文章

【算法竞赛宝典】读文章

题目描述


代码展示

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 小时前
C++编译期多态实现
开发语言·c++·算法
scx201310041 小时前
20260129LCA总结
算法·深度优先·图论
2301_765703141 小时前
C++中的协程编程
开发语言·c++·算法
m0_748708051 小时前
实时数据压缩库
开发语言·c++·算法
小魏每天都学习1 小时前
【算法——c/c++]
c语言·c++·算法
智码未来学堂2 小时前
探秘 C 语言算法之枚举:解锁解题新思路
c语言·数据结构·算法
Halo_tjn2 小时前
基于封装的专项 知识点
java·前端·python·算法
春日见2 小时前
如何避免代码冲突,拉取分支
linux·人工智能·算法·机器学习·自动驾驶
副露のmagic2 小时前
更弱智的算法学习 day59
算法
m0_748233173 小时前
30秒掌握C++核心精髓
开发语言·c++