Modifications nomr variables

This commit is contained in:
Rick 2020-12-14 01:18:07 +01:00
parent 136d27fdcc
commit 040eaf1a62
Signed by: Rick
GPG key ID: 9570A7DB7CB2F436
2 changed files with 22 additions and 21 deletions

View file

@ -1,59 +1,59 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
void deuxPartie(FILE *ptr) void deux_partie(FILE *ptr)
{ {
int bornInf, bornSup; int born_inf, born_sup;
int find = 0; int find = 0;
char speChar; char spe_char;
char word[256]; char word[256];
fscanf(ptr, "%d-%d %c: %s", &bornInf, &bornSup, &speChar, word); fscanf(ptr, "%d-%d %c: %s", &born_inf, &born_sup, &spe_char, word);
while (!feof(ptr)) while (!feof(ptr))
{ {
if ((word[bornInf - 1] == speChar && word[bornSup - 1] != speChar) if ((word[born_inf - 1] == spe_char && word[born_sup - 1] != spe_char)
|| (word[bornInf - 1] != speChar && word[bornSup - 1] == speChar)) || (word[born_inf - 1] != spe_char && word[born_sup - 1] == spe_char))
{ {
find++; find++;
} }
fscanf(ptr, "%d-%d %c: %s", &bornInf, &bornSup, &speChar, word); fscanf(ptr, "%d-%d %c: %s", &born_inf, &born_sup, &spe_char, word);
} }
printf("%d bons mdp trouvés.\n", find); printf("%d bons mdp trouvés.\n", find);
} }
void premPartie(FILE *ptr) void prem_partie(FILE *ptr)
{ {
int bornInf, bornSup, i, nbOcc; int born_inf, born_sup, i, nbOcc;
int find = 0; int find = 0;
char speChar, readChar; char spe_char, read_char;
char word[256]; char word[256];
fscanf(ptr, "%d-%d %c: %s", &bornInf, &bornSup, &speChar, word); fscanf(ptr, "%d-%d %c: %s", &born_inf, &born_sup, &spe_char, word);
while (!feof(ptr)) while (!feof(ptr))
{ {
i = 0; i = 0;
nbOcc = 0; nbOcc = 0;
readChar = word[i]; read_char = word[i];
while (readChar != '\0') while (read_char != '\0')
{ {
if (readChar == speChar) if (read_char == spe_char)
{ {
nbOcc++; nbOcc++;
} }
i++; i++;
readChar = word[i]; read_char = word[i];
} }
if (nbOcc >= bornInf && nbOcc <= bornSup) if (nbOcc >= born_inf && nbOcc <= born_sup)
{ {
find++; find++;
} }
fscanf(ptr, "%d-%d %c: %s", &bornInf, &bornSup, &speChar, word); fscanf(ptr, "%d-%d %c: %s", &born_inf, &born_sup, &spe_char, word);
} }
printf("%d bons mdp trouvés.\n", find); printf("%d bons mdp trouvés.\n", find);

View file

@ -1,9 +1,10 @@
#include <stdio.h> #include <stdio.h>
#define FILENAME "input" #define FILENAME "input"
//#define FILENAME "test"
void premPartie(FILE *ptr); void prem_partie(FILE *ptr);
void deuxPartie(FILE *ptr); void deux_partie(FILE *ptr);
int main() int main()
{ {
@ -15,10 +16,10 @@ int main()
} }
printf("Traitement de la première partie…\n"); printf("Traitement de la première partie…\n");
premPartie(ptr); prem_partie(ptr);
fseek(ptr, 0, SEEK_SET); fseek(ptr, 0, SEEK_SET);
printf("\nTraitement de la deuxième partie…\n"); printf("\nTraitement de la deuxième partie…\n");
deuxPartie(ptr); deux_partie(ptr);
fclose(ptr); fclose(ptr);
return 0; return 0;