OUI, c'est l'idée
la réalisation est plutôt :
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
//fonction de vérification : trouver 'n' dans 'tab' , chercher jusqu'à tab[i]
bool dansTab(int n, int tab[], int i)
{
for (int j=0; j<i; j++)
if (tab[j]==n) return true;
return false;
}
int main()
{
//init du hasard
srand( (unsigned)time(0) );
//le tableau à remplir
int tab[10]={0};
for (int i=0; i<10; i++)//i est l'indice courant du tableau
{
int n;
do
n=rand()%10+1;
while (dansTab( n, tab, i));
tab[i]=n;
cout << n << endl;
}
return 0;
}
-------------------------------
Réponse au message :
-------------------------------
> merci
>
> Amicalement...
>
> SniPi
>
>

>
>
> -------------------------------
> Réponse au message :
> -------------------------------
>
> > int array[10] = {0};
> >
> > srand(timeGetTime());
> >
> > int ind = 0;
> > while(ind < 10)
> > {
> > int num = rand()%11+1;
> > bool found = false;
> >
> > for(int i = 0; i < 10; i++)
> > if(array[i] == num)
> > {
> > found = true;
> > break;
> > }
> > }
> >
> > if(!found)
> > array[ind++] = num;
> > }
> >
> > c un algo possible ms ya mieux j'en suis sur...
> >
> > -------------------------------
> > Réponse au message :
> > -------------------------------
> >
> > > Comment faire pr remplir automatiquement un tableau avec tout les entiers compirs entre 1 et 10 rangés ds un ordre aléatoires. Dc sans doublons.
> > >
> > > merci
> > >
> > > Amicalement...
> > >
> > > SniPi
> > >
> > >

> >
>