mirror of
https://github.com/Oxbian/CodingGame.git
synced 2025-07-07 12:24:23 +02:00
Adding the first coding game Challenges
This commit is contained in:
49
Easy_Challenges/mars_landers_1.c
Normal file
49
Easy_Challenges/mars_landers_1.c
Normal file
@ -0,0 +1,49 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
// the number of points used to draw the surface of Mars.
|
||||
int surface_n;
|
||||
scanf("%d", &surface_n);
|
||||
for (int i = 0; i < surface_n; i++) {
|
||||
// X coordinate of a surface point. (0 to 6999)
|
||||
int land_x;
|
||||
// Y coordinate of a surface point. By linking all the points together in a sequential fashion, you form the surface of Mars.
|
||||
int land_y;
|
||||
scanf("%d%d", &land_x, &land_y);
|
||||
}
|
||||
|
||||
// game loop
|
||||
while (1) {
|
||||
int X;
|
||||
int Y;
|
||||
// the horizontal speed (in m/s), can be negative.
|
||||
int h_speed;
|
||||
// the vertical speed (in m/s), can be negative.
|
||||
int v_speed;
|
||||
// the quantity of remaining fuel in liters.
|
||||
int fuel;
|
||||
// the rotation angle in degrees (-90 to 90).
|
||||
int rotate;
|
||||
// the thrust power (0 to 4).
|
||||
int power;
|
||||
scanf("%d%d%d%d%d%d%d", &X, &Y, &h_speed, &v_speed, &fuel, &rotate, &power);
|
||||
|
||||
// Write an action using printf(). DON'T FORGET THE TRAILING \n
|
||||
// To debug: fprintf(stderr, "Debug messages...\n");
|
||||
|
||||
int final_power = 0;
|
||||
// 2 integers: rotate power. rotate is the desired rotation angle (should be 0 for level 1), power is the desired thrust power (0 to 4).
|
||||
if (Y > 1500)
|
||||
final_power = 3;
|
||||
if (Y < 1500 && v_speed < -35)
|
||||
final_power = 4;
|
||||
|
||||
printf("0 %d\n",final_power);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user