【算法竞赛宝典】读文章

【算法竞赛宝典】读文章

题目描述


代码展示

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;
}
相关推荐
会编程的土豆1 小时前
【日常做题】 代码随想录(岛屿最大面积+寻宝)
数据结构·算法·图论
前进吧-程序员1 小时前
现代 C++ 异步编程:从零实现一个高性能 ThreadPool (C++20 深度实践)
开发语言·c++·c++20
阿洛学长1 小时前
汉洛塔结构思维
算法
木子n11 小时前
第2篇:坐标变换与数学基础:FOC算法的核心数学工具
算法·电机控制·foc
阿Y加油吧1 小时前
两道经典 DP 题:零钱兑换 & 单词拆分(完全背包 + 字符串 DP)
算法
pearlthriving1 小时前
c++当中的泛型思想以及c++11部分新特性
java·开发语言·c++
疯狂打码的少年1 小时前
有序线性表删除一个元素:顺序存储 vs 单链表,平均要移动多少个元素?
数据结构·算法·链表
y = xⁿ2 小时前
20天速通LeetCode day07:前缀和
数据结构·算法·leetcode
t***5442 小时前
Dev-C++中哪些选项可以设置
开发语言·c++
载数而行5202 小时前
算法集训1:模拟,枚举,错误分析,前缀和,差分
算法