【算法竞赛宝典】读文章

【算法竞赛宝典】读文章

题目描述


代码展示

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;
}
相关推荐
hold?fish:palm1 分钟前
RDB全量快照备份
c++·redis·后端
什巳13 分钟前
JAVA练习306- 翻转二叉树
java·数据结构·算法·leetcode
smj2302_7968265220 分钟前
解决leetcode第3989题网格中保持一致的最大列数
python·算法·leetcode
盐焗鹌鹑蛋1 小时前
【C++】C++11:列表初始化、声明、STL升级
c++
巧克力男孩dd2 小时前
Python超典型练习题(第一次作业)
开发语言·python·算法
爱刷碗的苏泓舒2 小时前
平方根信息滤波:矩阵推导及 GNSS 参数估计应用
线性代数·算法·矩阵·gnss·参数估计·测量平差·平方根信息滤波
想做小南娘,发现自己是女生喵3 小时前
第 2 章 顺序表和 vector
java·数据结构·算法
ComputerInBook3 小时前
c 和 c++ 中的宏块(macro)
c语言·c++··宏块·宏指令
艾醒3 小时前
2026年第29周(7.13-7.19)AI全复盘:技术突破、行业趣闻翻车、算力服务器商业动态
人工智能·算法
AA陈超4 小时前
004 T02 - 俯视角摄像机系统 设计文档
网络·c++·ue5·虚幻引擎