Ajout première partie

This commit is contained in:
Rick 2020-12-15 19:25:03 +01:00
parent b40076f101
commit 312de614b8
Signed by: Rick
GPG key ID: 9570A7DB7CB2F436
2 changed files with 1051 additions and 0 deletions

1000
jour9/input Normal file

File diff suppressed because it is too large Load diff

51
jour9/main.c Normal file
View file

@ -0,0 +1,51 @@
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#define NBVAL 25
void prem_partie(FILE *ptr)
{
int val, find = 0;
int i = 0, j, k;
int first = 0; /* permet de check si on a bien fait les n premiers */
int prev_val[NBVAL]; /* tableau contenant les n valeurs précédentes */
fscanf(ptr, "%d", &val);
while (!feof(ptr) && !find)
{
if (first < NBVAL)
first++;
else
{
j = 0;
while (j < NBVAL && !find)
{
k = 0;
while (k < NBVAL && !find)
{
if (k != j && !find)
find = prev_val[j] + prev_val[k] == val ? 1 : 0;
k++;
}
j++;
}
find = find ? 0 : 1;
}
i = (i+1) % NBVAL;
if (!find)
{
prev_val[i] = val;
fscanf(ptr, "%d", &val);
}
}
printf("La première valeur ne correspondant pas est %d.", val);
}
void deux_partie(FILE *ptr)
{
}