forked from menault/2026_TD3_DEV51_Qualite_Algo
F6
This commit is contained in:
@@ -148,6 +148,19 @@ long meilleure_periode(const long *totaux, int nb_jours, int *debut, int *fin)
|
|||||||
/* F6 : retrouve une transaction à partir de son id */
|
/* F6 : retrouve une transaction à partir de son id */
|
||||||
const Transaction *rechercher_par_id(const Transaction *t, int n, int id)
|
const Transaction *rechercher_par_id(const Transaction *t, int n, int id)
|
||||||
{
|
{
|
||||||
|
static const Transaction *index[NB_TRANSACTIONS];
|
||||||
|
static const Transaction *transactions_indexees;
|
||||||
|
static int taille_indexee;
|
||||||
|
|
||||||
|
if (n <= NB_TRANSACTIONS && (t != transactions_indexees || n != taille_indexee)) {
|
||||||
|
for (int i = 0; i < n; i++)
|
||||||
|
index[t[i].id] = &t[i];
|
||||||
|
transactions_indexees = t;
|
||||||
|
taille_indexee = n;
|
||||||
|
}
|
||||||
|
if (n <= NB_TRANSACTIONS && id >= 0 && id < n && t == transactions_indexees)
|
||||||
|
return index[id];
|
||||||
|
|
||||||
for (int i = 0; i < n; i++)
|
for (int i = 0; i < n; i++)
|
||||||
if (t[i].id == id)
|
if (t[i].id == id)
|
||||||
return &t[i];
|
return &t[i];
|
||||||
|
|||||||
Reference in New Issue
Block a user