Voilà j'ai un petit problème j'arrive pas à trier mon vecteur (selon un ordre croissant)
Voilà un bout de mon algo donc si vous pouviez m'aider svp.....
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <vector>
using namespace std ;
int hasard(int min, int max, int prec)
{srand(time(NULL)+prec);
int nb;
nb=rand() % (max-min) + min;
return nb; }
main ()
{ int a, b, c, d, e, i, n, p, j, temp ;
vector<int> vect(5) ;
a=hasard(min, max, 1);
b=hasard(min, max, a);
c=hasard(min, max, b);
d=hasard(min, max, c);
e=hasard(min, max, d);
vect[1]=a;
vect[2]=b;
vect[3]=c;
vect[4]=d;
vect[5]=e;
(c'est cette partie qui marche pas...)
for (i= =1; i= =4; i++)
{for (j= =i; j= =5; j++)
{if (vect[i]>vect[j])
{temp= =vect[i];
vect[i]= =vect[j];
vect[j]= =temp;}
}
}
et quand je mets
cout<<vect[1]<<vect[2]<<vect[3]<<vect[4]<<vect[5]; ça me les affiche pas dans l'ordre