mirror of
https://github.com/Oxbian/CodingGame.git
synced 2025-06-12 06:08:07 +02:00
Fixing bug 2
This commit is contained in:
parent
1d98c8e0c5
commit
241344d98b
@ -1,42 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int W,H;
|
||||
scanf("%d%d", &W, &H);
|
||||
int N;
|
||||
scanf("%d", &N);
|
||||
int X0,Y0;
|
||||
scanf("%d%d", &X0, &Y0);
|
||||
|
||||
int LX = 0, LY = 0, HX = W - 1, HY = H - 1;
|
||||
// game loop
|
||||
while (1) {
|
||||
// the direction of the bombs from batman's current location (U, UR, R, DR, D, DL, L or UL)
|
||||
char bomb_dir[4];
|
||||
scanf("%s", bomb_dir);
|
||||
fprintf(stderr,"La bombe est dans la direction: %s",bomb_dir);
|
||||
|
||||
if (bomb_dir[0] == 'L' || bomb_dir[1] == 'L')
|
||||
HX = X0 - 1;
|
||||
else if (bomb_dir[0] == 'R' || bomb_dir[1] == 'R')
|
||||
LX = X0 + 1;
|
||||
|
||||
if (bomb_dir[0] == 'U')
|
||||
HY = Y0 - 1;
|
||||
else
|
||||
LY = Y0 + 1;
|
||||
|
||||
X0 = (HX + LX) /2;
|
||||
Y0 = (HY + LY) /2;
|
||||
|
||||
|
||||
// the location of the next window Batman should jump to.
|
||||
printf("%d %d\n",X0,Y0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int n, v, max = 0, max_lost =0, curr_lost = 0;
|
||||
scanf("%d", &n);
|
||||
for (int i = 0; i < n; i++) {
|
||||
scanf("%d", &v);
|
||||
|
||||
curr_lost = v-max;
|
||||
if (curr_lost < max_lost) max_lost = curr_lost;
|
||||
if (v>max) max = v;
|
||||
}
|
||||
printf("%d\n",max_lost);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
// the number of cells on the X axis
|
||||
int width;
|
||||
scanf("%d", &width);
|
||||
|
||||
// the number of cells on the Y axis
|
||||
int height;
|
||||
scanf("%d", &height); fgetc(stdin);
|
||||
|
||||
// New grid which will contains all the stuff
|
||||
char grid[30][30];
|
||||
|
||||
//Getting items from input and adding them into the grid
|
||||
for (int i = 0; i < height; i++) {
|
||||
char line[32];
|
||||
scanf("%[^\n]", line); fgetc(stdin);
|
||||
|
||||
for(int j =0;j < 32; j++){
|
||||
grid[i][j] = line[j];
|
||||
}
|
||||
}
|
||||
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
//If we found a node, we print it's coordonnate and after check his neighbours
|
||||
if (grid[y][x] == '0')
|
||||
{
|
||||
printf("%d %d ",x,y);
|
||||
short x2, y2, ansX = -1, ansY = -1;
|
||||
for (x2 = x+1; x2 < width; ++x2) //Checking if we found another node on the same line
|
||||
{
|
||||
if (grid[y][x2] == '0') //If node found we add it as neightbours and stop searching
|
||||
{
|
||||
ansX = x2;
|
||||
ansY = y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
printf("%d %d ",ansX, ansY);
|
||||
ansX = -1; ansY = -1;
|
||||
for (y2 = y+1; y2 < height; ++y2) //Checking if we found another node on the same column
|
||||
{
|
||||
if (grid[y2][x] == '0') //If we found we add it as neightbours and stop searching
|
||||
{
|
||||
ansX = x;
|
||||
ansY = y2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
printf("%d %d\n",ansX, ansY);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user