【算法竞赛宝典】读文章

【算法竞赛宝典】读文章

题目描述


代码展示

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;
}
相关推荐
Rabitebla2 分钟前
【数据结构】消失的数字+ 轮转数组:踩坑详解
c语言·数据结构·c++·算法·leetcode
菜菜的顾清寒4 分钟前
力扣100(20)旋转图像
算法·leetcode·职场和发展
Navigator_Z4 分钟前
LeetCode //C - 1025. Divisor Game
c语言·算法·leetcode
深念Y4 分钟前
王者荣耀与英雄联盟数值设计对比:穿透、乘算与加算、增伤乘算更厉害,减伤加算更厉害
数学·算法·游戏·建模·游戏策划·moba·数值
budingxiaomoli12 分钟前
优选算法-多源bfs解决拓扑排序问题
算法·宽度优先
隔壁大炮12 分钟前
10.PyTorch_元素类型转换
人工智能·pytorch·深度学习·算法
The Chosen One98513 分钟前
算法题目分享(二分算法)
算法·职场和发展·蓝桥杯
玛丽莲茼蒿15 分钟前
Leetcode hot100 矩阵置零【中等】
算法·leetcode·矩阵
Queenie_Charlie16 分钟前
关于二叉树(2)
数据结构·c++·二叉树·简单树结构
澈20716 分钟前
算法进阶:二叉树翻转与环形链表解析
数据结构·算法·排序算法