【算法竞赛宝典】读文章

【算法竞赛宝典】读文章

题目描述


代码展示

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;
}
相关推荐
地平线开发者15 分钟前
征程 6E/M Matrix 开发评板使用系列(一):开箱与点亮
算法·自动驾驶
Jerry32 分钟前
LeetCode 59. 螺旋矩阵 II
算法
可编程芯片开发44 分钟前
基于FOC控制器的BLDC无刷直流电机控制系统matlab编程与仿真
算法
瓶中怪1 小时前
ROS2 机器人软件系统
linux·c++·python·ubuntu·vmware·ros2·机器人软件开发
从零开始的代码生活_1 小时前
NAT、代理服务与内网穿透详解
linux·服务器·网络·c++·http·智能路由器
aaaameliaaa1 小时前
进制练习题【找出只出现一次的数字、交换两个变量(不创建临时变量)、统计二进制中1的个数、打印整数二进制的奇数位和偶数位、求两个数二进制中不同位的个数】
c语言·数据结构·笔记·算法
charlie1145141912 小时前
Cinux: 加载第一个内核:从 bootloader 跳进 C++
linux·开发语言·c++·嵌入式
QiLinkOS3 小时前
第三视觉理解徐玉生与他的商业活动(28)
大数据·c++·人工智能·算法·开源协议
星夜夏空993 小时前
C++学习(2) —— 类与对象基础
开发语言·c++·学习
wabs6663 小时前
关于动态规划【力扣1143.最长公共子序列的思考】
算法·leetcode·动态规划