当前位置:网站首页>用函数统计最长单词的字母数量
用函数统计最长单词的字母数量
2022-08-09 22:18:00 【DHU杨骅麟(紫外线过敏)】
很简单的问题记录一下
经济学问题正在努力创作中 请耐心等待
#include<iostream>
using namespace std;
struct student
{
string letter;
int length=0;
};
int find_length(student arr[])
{
int max = 0;
for (int i = 0; i < 100; i++)
{
if (arr[i].length > max)
{
max = arr[i].length;
}
}
return max;
}
int main()
{
student arr[100];
cout << "接下来请输入你要输入的单词,用空格隔开,输入完毕先按回车然后按住ctrl+z再按回车" << endl;
for (int i = 0; i < 100; i++)
{
cin >> arr[i].letter;
arr[i].length = arr[i].letter.length();
}
int temp=find_length(arr);
cout << "输出最长单词的字母数:" << endl;
cout << temp << endl;
return 0;
}
边栏推荐
- Live Preview | ICML 2022 11 first-author scholars share online neural network, graph learning and other cutting-edge research
- LeetCode_2632_字符串压缩
- Day 12 of learning to program
- Bi Sheng Compiler Optimization: Lazy Code Motion
- Install win7 virtual machine in Vmware and related simple knowledge
- 函数习题(下)
- 国内十大活跃报表 BI 产品深度对比及点评
- 2022-08-09 mysql/stonedb-subquery performance improvement-introduction
- 2022-8-9 第六组 输入输出流
- 高手这样看现货白银走势图
猜你喜欢
How to know the computer boot record?
Mysql/stonedb - slow SQL - 2022-08-09 Q16 analysis
Chapter 15 HMM模型
2022-08-09 mysql/stonedb-慢SQL-Q16分析
【接口测试】requests 库请求体字符串解码
torch.distributed多卡/多GPU/分布式DPP(二)——torch.distributed.all_reduce(reduce_mean)&barrier&控制进程执行顺序&随机数种子
直播预告 | ICML 2022 11位一作学者在线分享神经网络,图学习等前沿研究
[Cloud Native] This article explains how to add Tencent Crane to Kubevela addon
用哈希简单封装unordered_map和unordered_set
金仓数据库 KingbaseGIS 使用手册(6.4. 几何对象存取函数)
随机推荐
金仓数据库 KingbaseGIS 使用手册(6.2. 管理函数)
YGG 经理人杯总决赛已圆满结束,来看看这份文字版总结!
【哲理】事教人
少儿编程 电子学会图形化编程等级考试Scratch三级真题解析(判断题)2022年6月
Sun Zhengyi lost 150 billion: it was expensive at the beginning
[Cloud Native] This article explains how to add Tencent Crane to Kubevela addon
2022/8/9 考试总结
[Interface Test] Decoding the request body string of the requests library
全球不用交税的国家,为什么不交
setter与getter访问器属性——数据驱动显示
tiup cluster stop
Analyses the development status quo of stock trading
打包报错 AAPT: error: failed to read PNG signature: file does not start with PNG signature.
中国SaaS企业排名,龙头企业Top10梳理
软考 --- 软件工程(7)软件项目管理(下)
五分钟商学院(基础---商业篇)
力扣:377. 组合总和 Ⅳ
2022年最新《谷粒学院开发教程》:10 - 前台支付模块
Miscellaneous talk - the sorrow of programmers
68. qt quick-qml multi-level folding drop-down navigation menu supports dynamic add/unload, support qml/widget loading, etc.