【算法竞赛宝典】读文章

【算法竞赛宝典】读文章

题目描述


代码展示

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;
}
相关推荐
知乎的哥廷根数学学派10 分钟前
基于数据驱动的自适应正交小波基优化算法(Python)
开发语言·网络·人工智能·pytorch·python·深度学习·算法
ADI_OP28 分钟前
ADAU1452的开发教程10:逻辑算法模块
算法·adi dsp中文资料·adi dsp·adi音频dsp·adi dsp开发教程·sigmadsp的开发详解
xingzhemengyou142 分钟前
C语言 查找一个字符在字符串中第i次出现的位置
c语言·算法
Dream it possible!1 小时前
LeetCode 面试经典 150_二分查找_在排序数组中查找元素的第一个和最后一个位置(115_34_C++_中等)
c++·leetcode·面试
月光下的麦克2 小时前
如何查案动态库版本
linux·运维·c++
小六子成长记3 小时前
【C++】:搜索二叉树的模拟实现
数据结构·c++·算法
汉克老师3 小时前
GESP2025年9月认证C++二级真题与解析(编程题1(优美的数字))
c++·算法·整除·枚举算法·求余·拆数
carver w3 小时前
MFC入门教程 最简版
c++·mfc
王老师青少年编程3 小时前
信奥赛C++提高组csp-s之倍增算法
c++·csp·信奥赛·csp-s·提高组·倍增算法·rmq
低频电磁之道3 小时前
编译C++的几种方式(MSVC编译器)
开发语言·c++