mirror of
https://codeberg.org/andyscott/exercism.git
synced 2024-11-10 13:50:46 -05:00
36 lines
632 B
C
36 lines
632 B
C
#include "space_age.h"
|
|
#include <stdint.h>
|
|
|
|
float age(planet_t planet, int64_t seconds) {
|
|
|
|
float years = seconds / 31557600.0f;
|
|
switch (planet) {
|
|
case MERCURY:
|
|
years = years / 0.2408467f;
|
|
break;
|
|
case VENUS:
|
|
years = years / 0.61519726f;
|
|
break;
|
|
case EARTH:
|
|
break;
|
|
case MARS:
|
|
years = years / 1.8808158f;
|
|
break;
|
|
case JUPITER:
|
|
years = years / 11.862615f;
|
|
break;
|
|
case SATURN:
|
|
years = years / 29.447498f;
|
|
break;
|
|
case URANUS:
|
|
years = years / 84.016846f;
|
|
break;
|
|
case NEPTUNE:
|
|
years = years / 164.79132f;
|
|
break;
|
|
default:
|
|
years = -1;
|
|
}
|
|
|
|
return years;
|
|
}
|