【算法竞赛宝典】读文章

【算法竞赛宝典】读文章

题目描述


代码展示

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;
}
相关推荐
DeepVis Research11 分钟前
【AGI/Simulation】2026年度通用人工智能图灵测试与高频博弈仿真基准索引 (Benchmark Index)
大数据·人工智能·算法·数据集·量化交易
努力学算法的蒟蒻14 分钟前
day52(1.3)——leetcode面试经典150
算法·leetcode·面试
w陆压14 分钟前
2.区分C++中相似但不同的类型
c++·c++基础知识
十五年专注C++开发20 分钟前
CMake进阶:vcpkg中OpenSSLConfig.cmake详解
c++·windows·cmake·openssl·跨平台编译
leoufung28 分钟前
LeetCode 97. 交错字符串 - 二维DP经典题解(C语言实现)
c语言·算法·leetcode
郑同学的笔记1 小时前
【Eigen教程02】深入Eigen矩阵引擎:模板参数、内存布局与基础操作指南
c++·线性代数·矩阵·eigen
wadesir1 小时前
C++基本数据类型详解(零基础掌握C++核心数据类型)
java·开发语言·c++
leiming63 小时前
c++ map容器
开发语言·c++·算法
杨校3 小时前
杨校老师课堂备赛C++信奥之模拟算法习题专项训练
开发语言·c++·算法
世洋Blog3 小时前
AStar算法基础学习总结
算法·面试·c#·astar·寻路