一、原题
链接:Training on A snail enters a bar! | Codewars
Problem Description: A snail is crawling along a rubber band that has an initial length of |
二、解题
1、分析
蜗牛匀速爬行时,橡皮筋会在原有长度基础上匀速变长,计算蜗牛在一年内能否爬到橡皮筋另一端。
2.思路
1)判断(蜗牛速度-橡皮筋速度)*60*24*365>橡皮筋长度 是否为真
2)为真返回true,否则返回false
三、Myway
#include <stdbool.h>
bool canSnailReachEnd(double length, double speed, double lengthIncreases) {
//code
if((speed-lengthIncreases)*60*24*365>length)
return true;
else return false;
}