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;

}

相关推荐
星空椰2 小时前
Python 面向对象高级:继承与类定义详解
开发语言·python
wunaiqiezixin2 小时前
如何在C++中创建和管理线程
c++
白露与泡影3 小时前
2026大厂Java面试题大全!牛客网最新版
java·开发语言
凯瑟琳.奥古斯特3 小时前
高阶子查询题目精炼
开发语言·数据库·python·职场和发展·数据库开发
雪度娃娃3 小时前
转向现代C++——在意为改写的函数添加 override
开发语言·c++
王老师青少年编程3 小时前
csp信奥赛C++高频考点专项训练之前缀和&差分 --【一维差分】:[NOIP 2018 提高组] 铺设道路
c++·前缀和·差分·csp·高频考点·信奥赛·铺设道路
星马梦缘3 小时前
aaaaa
数据结构·c++·算法
喵星人工作室4 小时前
C++火影忍者1.1.2
开发语言·c++
basketball6165 小时前
C++ 中的 ptrdiff_t 详解
开发语言·c++
wunaiqiezixin5 小时前
互斥锁与自旋锁的区别
c++