Adding python files

This commit is contained in:
Arkagedon
2022-03-13 19:40:00 +01:00
parent 96c71d1d71
commit 70f29fa19e
22 changed files with 320 additions and 32 deletions

View File

@ -1,11 +1,8 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
int main()
{
//Getting the data
int L;
scanf("%d", &L);
int H;
@ -21,13 +18,14 @@ int main()
}
int size=0;
//On compte la taille du mot
//Counting the size of the word
for (int i =0; i < 257; i++)
{
if (T[i] != '\0')
{
size++;
//On convertit notre mot
//Convert the word
if (T[i] > 96 && T[i] < 123)
T[i] -= 32;
}
@ -35,10 +33,10 @@ int main()
break;
}
//Affichage du mot
for (int i = 0; i < H; i++) //On répète ça le nombre de lignes
//Printing the word
for (int i = 0; i < H; i++) //Repeat number of line times
{
for (int j = 0; j< size; j++) //Répétition du nombre de lettre pour afficher la ligne i de chaque lettre
for (int j = 0; j< size; j++) //Repeat number of letter times
{
int id = T[j] - 65;
//fprintf(stderr,"T = %d Id= %d\n",T[j],id);
@ -59,8 +57,6 @@ int main()
}
printf("\n");
}
// Write an answer using printf(). DON'T FORGET THE TRAILING \n
// To debug: fprintf(stderr, "Debug messages...\n");
return 0;
}

Binary file not shown.

View File

@ -0,0 +1,25 @@
#include <stdlib.h>
#include <stdio.h>
int compare (const void *arg1, const void *arg2) {
return (*(int*)arg1 - *(int*)arg2);
}
int main()
{
int N, diff = 2147483647;
scanf("%d", &N);
int tab[N];
for (int i = 0; i < N; i++)
scanf("%d", &tab[i]);
qsort (tab,N,sizeof(int),compare);
for (int i =0; i<N; i++)
{
if (abs(tab[i] - tab[i+1]) < diff)
diff = abs(tab[i] - tab[i+1]);
}
printf("%d\n",diff);
return 0;
}

View File

@ -1,8 +1,5 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main()
{
// the number of points used to draw the surface of Mars.

View File

@ -0,0 +1,23 @@
int main()
{
// game loop
while (1) {
char enemy1[257]; // name of enemy 1
scanf("%s", enemy1);
int dist1; // distance to enemy 1
scanf("%d", &dist1);
char enemy2[257]; // name of enemy 2
scanf("%s", enemy2);
int dist2; // distance to enemy 2
scanf("%d", &dist2);
if (dist1 < dist2) {
printf("%s\n", enemy1);
} else {
printf("%s\n", enemy2);
}
}
return 0;
}

View File

@ -1,7 +1,4 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
int main()
{
@ -17,8 +14,7 @@ int main()
scanf("%d%d%d%d", &light_x, &light_y, &initial_tx, &initial_ty);
// game loop
while (1)
{
while (1) {
// The remaining amount of turns Thor can move. Do not remove this line.
int remaining_turns;
scanf("%d", &remaining_turns);
@ -29,19 +25,37 @@ int main()
if ((initial_tx >= 0 && initial_tx < 40) && (initial_ty >= 0 && initial_ty < 18))
{
if (initial_tx > light_x)
dirX = "W", initial_tx--;
{
dirX = "W";
initial_tx--;
}
else if (initial_tx < light_x)
dirX = "E", initial_tx++;
{
dirX = "E";
initial_tx++;
}
else
{
dirX = "";
}
if (initial_ty > light_y)
dirY = "N", initial_ty--;
{
dirY = "N";
initial_ty--;
}
else if (initial_ty < light_y)
dirY = "S", initial_ty++;
{
dirY = "S";
initial_ty++;
}
else
{
dirY = "";
}
}
printf("%s%s\n", dirY, dirX);
}

View File

@ -1,6 +1,4 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//Convert char into binary ascii
void charToBin(char c, char *buffer)