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(str[i] >= 65 && str[i] <= 90)

{

cl++;

}

else if(str[i]>=97 && str[i]<=122)

{

ll++;

}

else if(str[i]>=48 && str[i]<=57)

{

figure++;

}

else if(str[i]==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;

}

相关推荐
卡戎-caryon12 分钟前
【C++】15.并发支持库
java·linux·开发语言·c++·多线程
90后小陈老师18 分钟前
WebXR教学 09 项目7 使用python从0搭建一个简易个人博客
开发语言·python·web
tyatyatya21 分钟前
MATLAB 神经网络的系统案例介绍
开发语言·神经网络·matlab
hweiyu0032 分钟前
C#学习教程(附电子书资料)
开发语言·学习·c#
q5673152334 分钟前
图片爬虫通过模板及使用说明
开发语言·爬虫·tcp/ip·golang
superior tigre39 分钟前
C++学习:六个月从基础到就业——C++11/14:列表初始化
c++·学习
正在走向自律1 小时前
Conda 完全指南:从环境管理到工具集成
开发语言·python·conda·numpy·fastapi·pip·开发工具
啊吧怪不啊吧1 小时前
C/C++之内存管理
开发语言·汇编·c++
北极象1 小时前
Go语言处理HTTP下载中EOFFailed
开发语言·http·golang
superior tigre1 小时前
C++学习:六个月从基础到就业——C++11/14:decltype关键字
c++·学习