【算法竞赛宝典】读文章

【算法竞赛宝典】读文章

题目描述


代码展示

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;
}
相关推荐
mit6.82435 分钟前
dfs|前后缀分解
算法
扫地的小何尚1 小时前
NVIDIA RTX PC开源AI工具升级:加速LLM和扩散模型的性能革命
人工智能·python·算法·开源·nvidia·1024程序员节
苦藤新鸡2 小时前
8.最长的无重复字符的子串
c++·力扣
千金裘换酒2 小时前
LeetCode反转链表
算法·leetcode·链表
꧁Q༒ོγ꧂3 小时前
C++ 入门完全指南(四)--函数与模块化编程
开发语言·c++
byzh_rc3 小时前
[认知计算] 专栏总结
线性代数·算法·matlab·信号处理
汉克老师3 小时前
GESP2025年12月认证C++八级真题与解析(判断题8-10)
c++·快速排序··lcs·gesp八级·gesp8级
qq_433554543 小时前
C++ manacher(求解回文串问题)
开发语言·c++·算法
歌_顿3 小时前
知识蒸馏学习总结
人工智能·算法
闲看云起4 小时前
LeetCode-day6:接雨水
算法·leetcode·职场和发展