Bonsoir, j'ai essayé de faire cet exercice sauf que sa me renvoie false et je ne comprend pas pourquoi merci d'avance :
Pour la première question pour le tableau trié avec une complexité O(n) j'ai fais ça;
Pour la 2eme question tableau non trié avec une complexité O(n)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 bool Tabmul(int T[],int n){ int s=1 ; int cpt=0; int i=0; while( i<n){ if(s*T[0] == T[i]){ cpt=cpt+1; s=s+1; i=i+1;} i=i+1;} if(cpt==n){ return true;} return false;}
aidez moi s'il vous plait merci
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 int mintab(int T[],int n){ min=T[0]; for(int i=1;i<n;i++){ if(min >T[i]){ min=T[i];} } return min;} bool Tabmul(int T[],int n){ int cpt=0; int s=1; for(int i=0;i<n;i++){ if(s*mintab(T,n)==T[i]){ cpt=cpt+1; i=0; s=s+1;} } if(cpt==n){ return true;} return false;}
Partager