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;

}

相关推荐
wuyk55513 分钟前
66.嵌入式C语言进阶:共用体(Union)实战指南——单片机内存省一半的神级技巧
c语言·开发语言·stm32·单片机·嵌入式硬件
怪奇云呼军20 分钟前
闪电智能 Voice Agent 怎样根据语速、停顿和追问方式切换话术?策略引擎拆解
开发语言·人工智能·网络协议·算法·语音识别·web app
努力努力再努力wz22 分钟前
【分布式系统与 RPC 框架系列】从单机瓶颈到远程调用:一文理解分布式架构与 RPC 原理
linux·网络·c++·分布式·网络协议·rpc·架构
Ivanqhz30 分钟前
Rust parse() 浅析
开发语言·后端·rust
神仙别闹39 分钟前
基于C++实现(控制台)景区旅游管理系统
开发语言·c++·旅游
牛奔9 小时前
Go 如何打印调试深层或嵌套的结构体
开发语言·后端·golang
geovindu9 小时前
go: Iterative Algorithms
开发语言·后端·算法·golang·迭代算法
学逆向的9 小时前
汇编——JCC指令
开发语言·汇编·网络安全
mayaairi10 小时前
JS循环语句深度解析:嵌套for、while与do...while
开发语言·前端·javascript
kite012111 小时前
Go语言Map深度解析与最佳实践
开发语言·后端·golang