当前位置:网站首页>Statistical words (DAY 101) Huazhong University of Science and Technology postgraduate examination questions
Statistical words (DAY 101) Huazhong University of Science and Technology postgraduate examination questions
2022-08-04 23:39:00 【Zhang Xueheng】
Article table of contents
1: Question
Write a program that reads a line of text input by the user that ends with . , counts how many words there are in total, and outputs how many characters each word contains.(Any part separated by one or more spaces is a word)input formatOne line containing a string ending with . .Note that the last word is immediately followed by a . to indicate the end of the sentence, but the . does not count towards the word.output formatA total of one line, in order to output the number of letters contained in each word in the string.data rangeString length cannot exceed 1000.Input sample:hello how are you.Sample output:5 3 3 3
2: Code Implementation
Keep reading while (cin>> s) str[k++]=s;
Read the input data into an array, complete the process of storage and ++
str[k]=s;
k++;
#include #include #include using namespace std;const int N=1010;string str[N];string s;int main(){int k=0;while(cin>> s)str[k++]=s;for(int i=0;i<k-1;i++)cout << str[i].size()<< '';cout << str[k-1].sizespan>()-1;return 0;}
边栏推荐
- ClickHouse 二级索引
- 小黑leetcode冲浪:94. 二叉树的中序遍历
- 手写分布式配置中心(1)
- Basic web in PLSQL
- 被领导拒绝涨薪申请,跳槽后怒涨9.5K,这是我的心路历程
- Will we still need browsers in the future?(feat. Maple words Maple language)
- uniapp sharing function - share to friends group chat circle of friends effect (sorting)
- 统计单词(DAY 101)华中科技大学考研机试题
- truffle
- Basic web in PLSQL
猜你喜欢
kernel hung_task死锁检测机制原理实现
【SSR服务端渲染+CSR客户端渲染+post请求+get请求+总结】
Xiaohei's leetcode journey: 95. Longest substring with at least K repeating characters
没有这些「伪需求」,产品经理的 KPI 怎么完成?
[Cultivation of internal skills of string functions] strlen + strstr + strtok + strerror (3)
OPENCV学习DAY8
Ab3d.PowerToys and Ab3d.DXEngine Crack
4 - "PyTorch Deep Learning Practice" - Backpropagation
Nuclei(二)进阶——深入理解workflows、Matchers和Extractors
三大技巧让你成功入门3D建模,零基础小白必看
随机推荐
情侣牵手[贪心 & 抽象]
一、爬虫基本概念
【SSR服务端渲染+CSR客户端渲染+post请求+get请求+总结】
2022年华数杯数学建模
什么是次世代建模(附学习资料)
[Happy Qixi Festival] How does Nacos realize the service registration function?
DNS常见资源记录类型详解
[Cultivation of internal skills of memory operation functions] memcpy + memmove + memcmp + memset (4)
kernel问题定位手段总结
Service Mesh landing path
堪称奔驰“理财产品”,空间媲美宝马X5,采用了非常运动的外观
jenkins发送邮件系统配置
中日颜色风格
2022年华数杯数学建模
建模师经验分享:模型学习方法
PID控制器改进笔记之七:改进PID控制器之防超调设定
MySQL基础篇【聚合函数】
如何根据地址获取函数名
Nuclei(二)进阶——深入理解workflows、Matchers和Extractors
Go 语言快速入门指南:什么是 TSL 安全传输层