2024-8-28作业C++/QT

代码:

#include <iostream>

#include <cstring>

#include <array>

#include <iomanip>

using namespace std;

int main()

{

//array<char,128> a;

//array<char,128>::iterator iter;

string str;

getline(cin,str);

int cl=0,ll=0,figure=0,blank=0,other=0;//依次是大写、小写字母、数字个数、空格个数

cout << "请输入字符串!" << endl;

/*for(iter = a.begin(); iter != a.end(); iter++)

{

cin >> *iter;

}*/

//int num=str.size();

for(int i=0;i<(int)str.size();i++)

{

if(stri >= 65 && stri <= 90)

{

cl++;

}

else if(stri>=97 && stri<=122)

{

ll++;

}

else if(stri>=48 && stri<=57)

{

figure++;

}

else if(stri==32)

{

blank++;

}

else

{

other++;

}

}

cout << "cl=" << cl <<endl;

cout << "ll=" << ll <<endl;

cout << "figure=" << figure <<endl;

cout << "blank=" << blank <<endl;

cout << "other=" << other <<endl;

return 0;

}

相关推荐
三8442 分钟前
redis三大机制:配置、持久化、主从复制(getshell 原理地基)
开发语言·php
hope_wisdom3 分钟前
C/C++数据结构之二叉树的遍历
c语言·数据结构·c++·二叉树·深度优先·广度优先
万年咸鱼6 分钟前
Java PrintStream 详解:从基础用法到实战技巧
java·开发语言·python
guwentian22 分钟前
手撕 MCP:用 TypeScript 从零写一个能跑的最小客户端(附可运行 demo)
开发语言·nodejs·mcp
Quz1 小时前
QML Page:把 Page 装进切换容器里
qt
秋田君1 小时前
Qt_串口编程
开发语言·qt
worilb1 小时前
Java/JVM 常见诊断文件对比
java·开发语言
ttwuai1 小时前
Go 后台初始化 MySQL 脚本失败怎么办?先查 DDL 还是生成配置
开发语言·mysql·golang
cpp_learner1 小时前
C++ 实现责任链模式(Chain of Responsibility):从一堆 if-else 到可插拔的处理管道
c++·设计模式
2601_962885721 小时前
如何用 Python 做 A 股全市场扫描选股?(多条件筛选实战)
开发语言·python