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;

}

相关推荐
leluckys几秒前
AI- 一种快速实现MCP服务的方法
开发语言·python
qq_401700415 分钟前
C语言 条件编译宏
c语言·开发语言
写代码的【黑咖啡】8 分钟前
探索 Python 中的 Vaex:高效处理大规模数据的新选择
开发语言·python
无限进步_12 分钟前
【C语言&数据结构】对称二叉树:镜像世界的递归探索
c语言·开发语言·数据结构·c++·git·算法·visual studio
JavaLearnerZGQ15 分钟前
1、Java中的线程
java·开发语言·python
X***078818 分钟前
C语言在嵌入式系统开发中的应用与挑战
c++
小芒果_0130 分钟前
整理归并排序
c++·算法·排序算法·信息学奥赛
松涛和鸣32 分钟前
49、智能电源箱项目技术栈解析
服务器·c语言·开发语言·http·html·php
huwei85338 分钟前
Q打印表格内容类
开发语言·qt
玖剹43 分钟前
队列+宽搜(bfs)
数据结构·c++·算法·leetcode·宽度优先