| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 
 |  
int main(void)
{
	using namespace std;
 
	//création d'un vecteur de 2 éléments choisis aléatoirement
	vector<double> v1(2);
	generate(v1.begin(), v1.end(), rand);
 
	//création d'un vecteur de 5 éléments choisis aléatoirement
	vector<double> v2(5);
	generate(v2.begin(), v2.end(), rand);
 
	//affichage du premier vecteur
	copy(v1.begin(), v1.end(), ostream_iterator<int>(cout, "\t"));
	cout << endl;
 
	//affichage du second vecteur
	copy(v2.begin(), v2.end(), ostream_iterator<int>(cout, "\t"));
	cout << endl;
 
	//création d'un vecteur de résultat de la concaténation des 2 vecteurs
	vector<double> v3;
	copy(v1.begin(), v1.end(), back_inserter<std::vector<double>>(v3));
	copy(v2.begin(), v2.end(), back_inserter<std::vector<double>>(v3));
 
	//tri du vecteur résultat
	sort(v3.begin(), v3.end());
 
	//affichage du vecteur trié
	copy(v3.begin(), v3.end(), ostream_iterator<int>(cout, "\t"));
	cout << endl;
} | 
Partager