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;

}

相关推荐
2301_8009769324 分钟前
正则表达式
开发语言·python·正则表达式
故事还在继续吗28 分钟前
C++20关键特性
开发语言·c++·c++20
青少儿编程课堂1 小时前
2026青少儿信息素养大赛备赛指南!Python/Scratch/C++备考要点
开发语言·c++·python
旖-旎1 小时前
深搜练习(电话号码字母组合)(3)
c++·算法·力扣·深度优先遍历
AIFarmer2 小时前
【无标题】
开发语言·c++·算法
昇腾CANN2 小时前
TileLang-Ascend 算子性能优化方法与实操
开发语言·javascript·性能优化·昇腾·cann
John_ToDebug2 小时前
WebHostView 与 TabStrip 交互机制深度解析
c++·chrome·windows
沐知全栈开发2 小时前
ionic 手势事件详解
开发语言
lsx2024062 小时前
Bootstrap 按钮
开发语言
神仙别闹2 小时前
基于 Python 实现 BERT 的情感分析模型
开发语言·python·bert