Modifs mineurs & changement message partie 2

This commit is contained in:
Rick 2021-01-04 15:17:01 +01:00
parent 6f5be3c839
commit 618fa1a301
Signed by: Rick
GPG key ID: 9570A7DB7CB2F436

View file

@ -52,39 +52,21 @@ void prem_partie(FILE *ptr)
void deux_partie(FILE *ptr) void deux_partie(FILE *ptr)
{ {
int *tab = NULL; int *tab = NULL;
int size = 2, born_inf = 0, read; int size = 2, born_inf = 0;
int find = 0, somme; int find = 0;
while (!feof(ptr) && !find) while (!feof(ptr) && !find)
{ {
tab = (int *) malloc(sizeof(int) * size); tab = (int *) malloc(sizeof(int) * size);
somme = 0;
for (int i = 0; i < size; i++)
{
fscanf(ptr, "%d", &read);
*(tab + i) = read;
somme += read;
}
born_inf++;
if (somme == prem)
find = 1;
while (!find && !feof(ptr)) while (!find && !feof(ptr))
{ {
somme = 0;
go_line(ptr, born_inf); go_line(ptr, born_inf);
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
{ fscanf(ptr, "%d", (tab + i));
fscanf(ptr, "%d", &read);
*(tab + i) = read;
somme += read;
}
if (sum_ptr(tab, size) == prem) if (sum_ptr(tab, size) == prem)
{
find = 1; find = 1;
}
born_inf++; born_inf++;
} }
@ -106,7 +88,8 @@ void deux_partie(FILE *ptr)
sup = *(tab+i); sup = *(tab+i);
} }
free(tab);
int last = sup + inf; int last = sup + inf;
printf("La première valeur ne correspondant pas est %d.\n", last); /*TODO modifier phrase*/ printf("La somme des nombres faisant %d est %d.\n", prem, last);
} }