【算法竞赛宝典】读文章

【算法竞赛宝典】读文章

题目描述


代码展示

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;
}
相关推荐
大侠归来19 分钟前
C 语言 | 在函数中操作数组
c语言·c++·算法
怕浪猫5 小时前
GEO 优化到底是什么?AI时代内容创作者必须懂的新技能
算法·面试·github
朝朝辞暮i6 小时前
C++ 第 23 课:class —— 开始真正进入面向对象
开发语言·c++·算法
Evand J7 小时前
【MATLAB例程】三维RRT+APF避障路径规划与到达角(AOA)定位算法|三维路径优化与定位仿真例程
算法·matlab·路径规划·代码·定位·rrt·aoa
郑同学的笔记8 小时前
【c++随笔28】strcmp 和 memcmp对比
开发语言·c++
随意起个昵称8 小时前
【背包dp】输出方案路径
c++·动态规划
weixin_307779138 小时前
有限产能智能排产与动态重排智能体:从需求解构到技术实现
开发语言·人工智能·算法·架构
朝朝辞暮i8 小时前
C++ 第 27 课:智能指针 shared_ptr
开发语言·c++·算法
by209999 小时前
学会使用std::string类,并理解其内部是如何管理字符串的详细阐述(上)
c++·笔记·字符串·类和对象·string
沙漠之主9 小时前
C++编程教学设计资料:从入门到实战的完整课程方案
java·前端·c++