【算法竞赛宝典】读文章

【算法竞赛宝典】读文章

题目描述


代码展示

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;
}
相关推荐
梵刹古音4 分钟前
【C语言】 递归函数
c语言·数据结构·算法
代码游侠13 分钟前
学习笔记——Linux内核与嵌入式开发3
开发语言·arm开发·c++·学习
yongui4783413 分钟前
混凝土二维随机骨料模型 MATLAB 实现
算法·matlab
酉鬼女又兒19 分钟前
JAVA牛客入门11~20
算法
怎么没有名字注册了啊26 分钟前
C++ 进制转换
开发语言·c++
代码游侠29 分钟前
C语言核心概念复习(二)
c语言·开发语言·数据结构·笔记·学习·算法
金枪不摆鳍33 分钟前
C++常用关键字考察
c++
XX風41 分钟前
2.1_binary_search_tree
算法·计算机视觉
不想写bug呀1 小时前
买卖股票问题
算法·买卖股票问题
-Try hard-1 小时前
完全二叉树、非完全二叉树、哈希表的创建与遍历
开发语言·算法·vim·散列表