【算法竞赛宝典】读文章

【算法竞赛宝典】读文章

题目描述


代码展示

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;
}
相关推荐
纪元A梦14 分钟前
贪心算法应用:配送路径优化问题详解
算法·贪心算法
姓刘的哦1 小时前
Qt中的QWebEngineView
数据库·c++·qt
C_player_0011 小时前
——贪心算法——
c++·算法·贪心算法
SundayBear1 小时前
QT零基础入门教程
c++·qt
kyle~2 小时前
排序---插入排序(Insertion Sort)
c语言·数据结构·c++·算法·排序算法
Boop_wu2 小时前
[数据结构] 队列 (Queue)
java·jvm·算法
奔跑吧邓邓子3 小时前
【C++实战⑦】C++函数实战:从基础到项目应用
c++·实战·函数
HMBBLOVEPDX3 小时前
C++(静态函数)
开发语言·c++
hn小菜鸡3 小时前
LeetCode 3643.垂直翻转子矩阵
算法·leetcode·矩阵
张晓~183399481213 小时前
短视频矩阵源码-视频剪辑+AI智能体开发接入技术分享
c语言·c++·人工智能·矩阵·c#·php·音视频