信息学集训队作业ural竞赛_第1页
免费预览已结束,剩余2页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、题目来源Ural 1612. Tram Forum题目描述得到一系列的字符,计算其中 tram trolleybus 出现的次数(必须单独出现,后面不能有其他字母)如果 tram 次数大于 trolleybus 则输出Tram driver,小于输出 Trolleybus driver 等于输出 Bus driver算法描述模拟算法实现用两个标号 k1,k2现在已经比较到第几个字符,如果读入字符不是字母若 k1=4 则出现了一次 tram若 k14 则k1:=0如果读入字符是字母比较 ch 与 tram 第 k1+1 位,相等 k1:=k1+1 否则 k1;=0;*可以将标准串最后一位添加不可

2、能出的字符,则可满足“后面不能有其他字母”的条件同理比较 k2 得出结果源代码const st1:string=tram1;st2:string=trolleybus1; var ch:char;k1,k2,a1,a2:eger; beginrepeatread(ch);if not (ch=a)and(cha2 then wri if a1a2 then wriend.n(Bus driver);n(Tram driver); n(Trolleybus driver);原题1612. Tram Forum Time Limit: 0.5 secondMemory Limit: 64 MBTr

3、am, trolleybus, and bus drivers talk at the tram forum. We have read allmessagested at the forum during last monnd discovered aneresting n therule. Users in whose messages the word “tram” occurs more oftenword “trolleybus” are tram drivers. Similarly, users in whose messages the word“trolleybus” is

4、more frequentn the word “tram” are trolleybus drivers. Allother users of the tram forum are bus drivers. Given this information, can youdetermine who hasted the latest message at the tram forum?InputYou are given the latest message at the tram forum. The message consists oflowercase English letters,

5、 spa, line breaks, and punctuation marks: periods,commas, dashes, colons, and exclamation and question marks. The total length of the message is at most 10000 symbols. Words consist of letters andcan be separated by spa, line breaks, and punctuation marks.OutputOutput “Tram driver” if the user who h

6、asted the latest message is a tramdriver; output “Trolleybus driver” if she is a trolleybus driver; and output “Bus driver” if she is a bus driver.Slesinputof course, tram is the best transport he world!yes, yekaterinburg trams are theoutputTram driverbest tramshe world, butTrolleybus driveri like my trolleybus too.read forum.tr.ru every day!you can learn much about tram drivers and trolleybus drivers.Bus driverProblem Author: Alexander Ipatov (

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论