codewars-018: Tortoise racing 烏龜賽跑

https://www.codewars.com/kata/55e2adece53b4cdcb900006c/train/javajava

//--https://www.codewars.com/kata/55e2adece53b4cdcb900006c/train/java
public class Tortoise{
  public static int[] race(int v1, int v2, int g){
    int h = 0;
    int mm = 0;
    int s = 0;
    if(v1 >= v2){
      return null;
    }
    s = 3600 * g / (v2 - v1);
    h = s / 3600;
    s = s - 3600 * h;
    mm = s / 60;
    s = s - 60 * mm;
    return new int[]{h,mm,s};
  }  
}
相關文章
相關標籤/搜索