Created
September 25, 2020 15:29
-
-
Save Dabsunter/b99a1c85e8f0212672bcb9b3c493878f to your computer and use it in GitHub Desktop.
Work until test-6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
const int MAX_WORD_LENGHT = 255; | |
int main(void) | |
{ | |
int n; | |
scanf("%d\n", &n); | |
char moteurs[n][MAX_WORD_LENGHT]; | |
for (int i = 0; i < n; i++) | |
{ | |
fgets(moteurs[i], MAX_WORD_LENGHT, stdin); | |
} | |
int moteursUtilises[n]; | |
for (int i = 0; i < n; i++) | |
{ | |
moteursUtilises[i] = 0; | |
} | |
int r; | |
scanf("%d\n", &r); | |
int changes = 0; | |
char requete[MAX_WORD_LENGHT]; | |
for (int i = 0; i < r; i++) | |
{ | |
fgets(requete, MAX_WORD_LENGHT, stdin); | |
int j = 0; | |
for (; j < n; j++) | |
{ | |
if (strcmp(requete, moteurs[j]) == 0) | |
{ | |
break; | |
} | |
} | |
if (j == n) | |
{ | |
continue; | |
} | |
moteursUtilises[j] = 1; | |
int increment = 1; | |
for (int k = 0; k < n; k++) | |
{ | |
if (!moteursUtilises[k]) | |
{ | |
increment = 0; | |
break; | |
} | |
} | |
if (increment) | |
{ | |
changes++; | |
for (int k = 0; k < n; k++) | |
{ | |
moteursUtilises[k] = 0; | |
} | |
} | |
} | |
printf("%d", changes); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment