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;

}

相关推荐
踩着两条虫2 小时前
「AI + 低代码」的可视化设计器
开发语言·前端·低代码·设计模式·架构
JoneBB2 小时前
ABAP Webservice连接
运维·开发语言·数据库·学习
即使再小的船也能远航2 小时前
【Python】安装
开发语言·python
Irissgwe2 小时前
类与对象(三)
开发语言·c++·类和对象·友元
️是782 小时前
信息奥赛一本通—编程启蒙(3395:练68.3 车牌问题)
数据结构·c++·算法
计算机安禾3 小时前
【c++面向对象编程】第24篇:类型转换运算符:自定义隐式转换与explicit
java·c++·算法
雪度娃娃3 小时前
转向现代C++——优先选用nullptr而不是0和NULL
开发语言·c++
我星期八休息3 小时前
Linux系统编程—基础IO
linux·运维·服务器·c语言·c++·人工智能·算法
萌新小码农‍3 小时前
python装饰器
开发语言·前端·python
KK溜了溜了3 小时前
Python从入门到精通
服务器·开发语言·python