17:文字排版
2018-06-17 23:09:37来源:未知 阅读 ()
17:文字排版
- 查看
- 提交
- 统计
- 提问
- 总时间限制:
- 1000ms
- 内存限制:
- 65536kB
- 描述
-
给一段英文短文,单词之间以空格分隔(每个单词包括其前后紧邻的标点符号)。请将短文重新排版,要求如下:
每行不超过80个字符;每个单词居于同一行上;在同一行的单词之间以一个空格分隔;行首和行尾都没有空格。
- 输入
- 第一行是一个整数n,表示英文短文中单词的数目. 其后是n个以空格分隔的英文单词(单词包括其前后紧邻的标点符号,且每个单词长度都不大于40个字母)。
- 输出
- 排版后的多行文本,每行文本字符数最多80个字符,单词之间以一个空格分隔,每行文本首尾都没有空格。
- 样例输入
-
84 One sweltering day, I was scooping ice cream into cones and told my four children they could "buy" a cone from me for a hug. Almost immediately, the kids lined up to make their purchases. The three youngest each gave me a quick hug, grabbed their cones and raced back outside. But when my teenage son at the end of the line finally got his turn to "buy" his ice cream, he gave me two hugs. "Keep the changes," he said with a smile.
- 样例输出
-
One sweltering day, I was scooping ice cream into cones and told my four children they could "buy" a cone from me for a hug. Almost immediately, the kids lined up to make their purchases. The three youngest each gave me a quick hug, grabbed their cones and raced back outside. But when my teenage son at the end of the line finally got his turn to "buy" his ice cream, he gave me two hugs. "Keep the changes," he said with a smile.
表示linux和windows的编译环境不一样,
在dev里格式错误但到了noi里满分,,,,
这就比较尴尬了,,1 #include<iostream> 2 using namespace std; 3 string kong; 4 string a[1001];//保存每个单词 5 int tot=1;//行数 6 int main() 7 { 8 int n; 9 cin>>n; 10 for(int i=1;i<=n;i++) 11 { 12 cin>>a[i]; 13 a[i]=a[i]+' '; 14 } 15 string ans; 16 for(int i=1;i<=n;i++) 17 { 18 if((ans.length()+a[i].length()-2)>=80) 19 { 20 if(ans.empty()==true) 21 continue; 22 cout<<ans; 23 cout<<endl; 24 ans=kong; 25 ans=ans+a[i]; 26 tot++; 27 } 28 else 29 { 30 ans=ans+a[i]; 31 } 32 } 33 cout<<ans; 34 return 0; 35 }
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:05:素数回文数的个数
下一篇:28:出现次数超过一半的数
- Qt5显示中文字符 2019-03-12
- L1-039 古风排版 2019-02-17
- 题解 P1435 【回文字串】 2018-08-13
- 32.QT-制作最强电压电阻表盘,可以自定义颜色,图标,文字标签- 2018-07-03
- 31.QPainter-rotate()函数分析-文字旋转不倾斜,图片旋转实现 2018-07-03
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash