摘要:
题目:整数取反题目很简单,完成函数reverse,要求实现把给定的一个整数取其相反数的功能,举两个例子如下:x = 123, return 321x = -123, return -321只完成功能函数int reverse(int x)即可。这道题虽然是最简单的,但是我第一次提交虽然测试数据对,但是没通过,更可恶的是还只能提交一次,没办法,我又注册一个账号修改代码后又交了一次,还是没对,不知道怎么回事,仔细检查了一番才发现有漏洞,我的原代码里有一条语句 x=x/abs(x); 这里没考虑到x=0的情况,修改代码后又重新注册了账号再提交,通过了!做题还得仔细啊,否则小小的Bug影响全局!代码: 阅读全文
摘要:
AntsTime Limit:1000MSMemory Limit:30000KTotal Submissions:7498Accepted:3457DescriptionAn army of ants walk on a horizontal pole of length l cm, each with a constant speed of 1 cm/s. When a walking ant reaches an end of the pole, it immediatelly falls off it. When two ants meet they turn back and sta 阅读全文