【算法竞赛宝典】读文章

【算法竞赛宝典】读文章

题目描述


代码展示

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;
}
相关推荐
HAPPY酷3 分钟前
C++ 多线程实战三板斧
java·开发语言·c++·技术美术
im_AMBER4 分钟前
Leetcode 121 翻转二叉树 | 二叉树中的最大路径和
数据结构·学习·算法·leetcode
fpcc4 分钟前
并行编程实战——CUDA编程的Tile
c++·cuda
mit6.8241 小时前
二分+贪心
算法
programhelp_2 小时前
特斯拉 MLE 超详细面经 + 避坑
数据结构·人工智能·算法·面试·职场和发展
越甲八千2 小时前
深入了解迭代器erase()之后的失效逻辑
算法
躺柒2 小时前
读人工智能全球格局:未来趋势与中国位势06人类的未来(下)
大数据·人工智能·算法·ai·智能
_风华ts2 小时前
C++ 函数封装与绑定
c++·函数指针·函数封装
ShineWinsu2 小时前
对于C++中stack和queue的详细介绍
开发语言·数据结构·c++·面试·stl·queue·stack
L_Aria2 小时前
6421. 【NOIP2019模拟11.11】匹配
c++·算法·动态规划