【算法竞赛宝典】读文章

【算法竞赛宝典】读文章

题目描述


代码展示

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;
}
相关推荐
bubiyoushang888几秒前
MATLAB实现雷达恒虚警检测
数据结构·算法·matlab
wu_asia4 分钟前
编程技巧:如何高效输出特定倍数数列
c语言·数据结构·算法
清 澜11 分钟前
c++高频知识点总结 第 1 章:语言基础与预处理
c++·人工智能·面试
AlenTech13 分钟前
207. 课程表 - 力扣(LeetCode)
算法·leetcode·职场和发展
fqbqrr30 分钟前
2601C++,模块基础
c++
带土130 分钟前
6. C++智能指针(1)
开发语言·c++
星火开发设计42 分钟前
C++ queue 全面解析与实战指南
java·开发语言·数据结构·c++·学习·知识·队列
橘颂TA1 小时前
【剑斩OFFER】算法的暴力美学——力扣 394 题:字符串解码
数据结构·c++·结构与算法
练习时长一年1 小时前
LeetCode热题100(杨辉三角)
算法·leetcode·职场和发展
lzllzz231 小时前
bellman_ford算法
算法