【算法竞赛宝典】读文章

【算法竞赛宝典】读文章

题目描述


代码展示

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;
}
相关推荐
子夜江寒8 分钟前
逻辑森林与贝叶斯算法简介
算法·机器学习
闻缺陷则喜何志丹16 分钟前
【计算几何 线性代数】仿射矩阵的秩及行列式
c++·线性代数·数学·矩阵·计算几何·行列式·仿射矩阵得秩
xu_yule30 分钟前
算法基础-背包问题(01背包问题)
数据结构·c++·算法·01背包
特立独行的猫a30 分钟前
C++ Core Guidelines(C++核心准则):2025现代C++开发关键要点总结
c++·core guidelines·核心准测
Joy-鬼魅37 分钟前
VC中共享内存的命名空间
c++·vc·共享内存命名空间
我不是小upper41 分钟前
从理论到代码:随机森林 + GBDT+LightGBM 融合建模解决回归问题
人工智能·深度学习·算法·随机森林·机器学习·回归
budingxiaomoli1 小时前
分治算法-快排
数据结构·算法
dragoooon341 小时前
[C++——lesson30.数据结构进阶——「红黑树」]
开发语言·数据结构·c++
云泽8081 小时前
C++ STL 栈与队列完全指南:从容器使用到算法实现
开发语言·c++·算法
前端小白在前进2 小时前
力扣刷题:复原IP地址
tcp/ip·算法·leetcode