Cold_Ants

所属分类:数学计算
开发工具:Visual Basic
文件大小:279KB
下载次数:1
上传日期:2015-06-19 00:18:35
上 传 者wjlwd
说明:  题目内容及要求:长100厘米的细长直杆子上有n只蚂蚁。它们的头有的朝左,有的朝右。 每只蚂蚁都只能沿着杆子向前爬,速度是1厘米/秒。 当两只蚂蚁碰面时,它们会同时掉头往相反的方向爬行。 这些蚂蚁中,有1只蚂蚁感冒了。并且在和其它蚂蚁碰面时,会把感冒传染给碰到的蚂蚁。 请你计算,当所有蚂蚁都爬离杆子时,有多少只蚂蚁患上了感冒。 【数据格式】 第一行输入一个整数n (1 < n < 50), 表示蚂蚁的总数。 接着的一行是n个用空格分开的整数 Xi (-100 < Xi < 100), Xi的绝对值,表示蚂蚁离开杆子左边端点的距离。正值表示头朝右,负值表示头朝左,数据中不会出现0值,也不会出现两只蚂蚁占用同一位置。其中,第一个数据代表的蚂蚁感冒了。 要求输出1个整数,表示最后感冒蚂蚁的数目。 例如,输入: 3 5 -2 8 程序应输出: 1 再例如,输入: 5 -10 8 -20 12 25 程序应输出: 3
(Subject content and requirements: n ants on slender 100 cm long straight pole. Some of them head to the left, some to the right.         Each ant can only crawl along the pole forward speed is 1 cm/sec.         When two ants meet, they will turn in the opposite direction while crawling.         These ants, ants have a cold. And when the other ants meet, the cold will spread to encounter ants.         Please work, when all the ants are crawling off the pole time, how many ants got sick. [Data format]         The first line of input an integer n (1 <n <50), represents the total number of ants.         The next line is the n space-separated integers Xi (-100 <Xi <100), the absolute value of Xi, expressed ants leave the pole to the left endpoint. A positive value indicates the head to the right, a negative value indicates the head to the left, the data does not appear in a va)

文件列表:
感冒蚂蚁 (0, 2015-06-19)
感冒蚂蚁\1.c (1365, 2014-10-19)
感冒蚂蚁\1.dsp (3339, 2014-10-19)
感冒蚂蚁\1.dsw (508, 2014-10-19)
感冒蚂蚁\1.ncb (41984, 2014-10-19)
感冒蚂蚁\1.opt (48640, 2014-10-19)
感冒蚂蚁\1.plg (236, 2014-10-19)
感冒蚂蚁\C实践教程2013.doc (247808, 2014-10-17)
感冒蚂蚁\Debug (0, 2014-10-19)
感冒蚂蚁\Debug\1.exe (208929, 2014-10-19)
感冒蚂蚁\Debug\1.ilk (244124, 2014-10-19)
感冒蚂蚁\Debug\1.obj (4975, 2014-10-19)
感冒蚂蚁\Debug\1.pch (175556, 2014-10-18)
感冒蚂蚁\Debug\1.pdb (476160, 2014-10-19)
感冒蚂蚁\Debug\vc60.idb (33792, 2014-10-19)
感冒蚂蚁\Debug\vc60.pdb (45056, 2014-10-19)
感冒蚂蚁\蚂蚁.txt (1364, 2014-10-19)

近期下载者

相关文件


收藏者