当前位置:网站首页>用函数统计最长单词的字母数量
用函数统计最长单词的字母数量
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;
}
边栏推荐
猜你喜欢
随机推荐
68.qt quick-qml多级折叠下拉导航菜单 支持动态添加/卸载 支持qml/widget加载等
Transfer Learning & Kemin Initialization
6款跨境电商常用工具汇总
What kind of mentality do you need to have when using the stock quantitative trading interface
70. Stair Climbing Advanced Edition
力扣:279.完全平方数
完全背包理论
带着昇腾去旅行:一日看尽金陵城里的AI胜景
Install win7 virtual machine in Vmware and related simple knowledge
LiveData : Transformations.map和 Transformations.switchMap用法
What is the stability of the quantitative trading interface system?
The 2022-8-9 sixth group of input and output streams
友元类和友元函数
国内十大活跃报表 BI 产品深度对比及点评
【接口测试】requests 库请求体字符串解码
matplotlib散点图颜色分组图例
harbor配置远程仓库
高手这样看现货白银走势图
Explore the TiDB Lightning source code to solve the found bugs
你的手机曾经被监控过吗?









