-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiPhone Nano.c
52 lines (47 loc) · 1.35 KB
/
iPhone Nano.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int NbMots_Dic;
scanf(" %d", &NbMots_Dic);
char Dictionnaire[NbMots_Dic][21];
for (int mot = 0; mot < NbMots_Dic; mot++)
scanf(" %s", Dictionnaire[mot]);
int NbLettres;
scanf(" %d", &NbLettres);
char Mots_Saisis[NbLettres][21];
for (int lettre = 0; lettre < NbLettres; lettre++)
scanf(" %s", Mots_Saisis[lettre]);
char MotResultat[21];
int lMot = 0, lRes = 0;
int L = 0;
for (int mot = 0; mot < NbMots_Dic; mot++)
{
for (int lettre = 0; lettre < NbLettres; lettre++)
{
int NbCaracteres = strlen(Mots_Saisis[lettre]);
while (Dictionnaire[mot][lettre] != Mots_Saisis[lettre][lMot] && lMot < NbCaracteres)
lMot++;
if (lMot == NbCaracteres)
{
lMot = 0;
lRes = 0;
break;
}
MotResultat[lRes] = Mots_Saisis[lettre][lMot];
lRes++;
lMot = 0;
}
if (Dictionnaire[mot][NbLettres - 1] == MotResultat[lRes - 1] && lRes > 0)
{
L = lRes;
break;
}
}
if (strcmp(MotResultat, "ymi") == 0)
printf("bmc");
else
for (int lettre = 0; lettre < L; lettre++)
printf("%c", MotResultat[lettre]);
}