当前位置:网站首页>用函数统计最长单词的字母数量
用函数统计最长单词的字母数量
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;
}
边栏推荐
猜你喜欢
少儿编程 电子学会图形化编程等级考试Scratch三级真题解析(判断题)2022年6月
数字与中文大写数字互转(5千万亿亿亿亿以上的数字也支持转换)
全球不用交税的国家,为什么不交
How to know the computer boot record?
Technology feast!Huayun Data brings six topics to OpenInfra Days China
为什么刀具数据库无法打开?
The 2022-8-9 sixth group of input and output streams
五分钟商学院(基础---商业篇)
探索TiDB Lightning源码来解决发现的bug
32 JZOF 】 【 print down on binary tree
随机推荐
2022/8/9 考试总结
【诗歌】枕上诗书
毕昇编译器优化:Lazy Code Motion
34. Fabric2.2 证书目录里各文件作用
JS中表单操作、addEventListener事件监听器
2020年度SaaS TOP100企业名单
LiveData : Transformations.map and Transformations.switchMap usage
新增一地公布2022下半年软考报考时间
torch.distributed多卡/多GPU/分布式DPP(二)——torch.distributed.all_reduce(reduce_mean)&barrier&控制进程执行顺序&随机数种子
Live Preview | ICML 2022 11 first-author scholars share online neural network, graph learning and other cutting-edge research
Pytorch分布式训练/多卡训练DDP——模型初始化(torch.distribute 与 DDP的区别)
complete knapsack theory
上海一科技公司刷单被罚22万,揭露网络刷单灰色产业链
【哲理】事教人
离散选择模型之Gumbel分布
68.qt quick-qml多级折叠下拉导航菜单 支持动态添加/卸载 支持qml/widget加载等
Comprehensive analysis of FPGA basics
深入理解多线程(第一篇)
Filament - Material basic graphics drawing
String类常用方法