当前位置:网站首页>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;}
边栏推荐
猜你喜欢
如何根据地址获取函数名
大师教你3D实时角色制作流程,游戏建模流程分享
招标公告 | 海纳百创公众号运维项目
kernel hung_task死锁检测机制原理实现
Uniapp dynamic sliding navigation effect demo (finishing)
~ hand AHB - APB Bridge 】 【 AMBA AHB bus
情侣牵手[贪心 & 抽象]
Nuclei (2) Advanced - In-depth understanding of workflows, Matchers and Extractors
407. 接雨水 II
Day118.尚医通:订单列表、详情、支付
随机推荐
情人节---快来学习一下程序员的专属浪漫吧
jenkins发送邮件系统配置
建模师经验分享:模型学习方法
[Cultivation of internal skills of string functions] strcpy + strcat + strcmp (1)
手写分布式配置中心(1)
PID Controller Improvement Notes No. 7: Improve the anti-overshoot setting of the PID controller
npm基本操作及命令详解
【七夕快乐篇】Nacos是如何实现服务注册功能的?
美团二面:Redis与MySQL双写一致性如何保证?
为何越来越多人选择进入软件测试行业?深度剖析软件测试的优势...
3年,从3K涨薪到20k?真是麻雀啄了牛屁股 — 雀食牛逼呀
@Import注解的作用以及如何使用
Web安全开发 | 青训营笔记
Linear DP (bottom)
基于深度学习的路面坑洞检测(详细教程)
typeScript-promise
零基础如何入门软件测试?再到测开(小编心得)
中日颜色风格
三、实战---爬取百度指定词条所对应的结果页面(一个简单的页面采集器)
未上市就“一举成名”,空间媲美途昂,安全、舒适一个不落