Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Afficher un tableau avec ‘copy()’

 iterator
{filelink=15333}

#include <algorithm>
#include <iostream>
#include <iterator>
 
using namespace std;
 
int main( )
{
    int num_costs = 4;
    double cost[4] = { 8.88, 6.77, 9.22, 4.11 };
 
	// Afficher le tableau
   copy( cost, cost + num_costs,ostream_iterator<double>( cout, " " ) );
     cout<<endl; 
 
   //trier le tableau
   sort( cost, cost + 4 );
 
   // Afficher le tableau
   copy( cost, cost + num_costs,ostream_iterator<double>( cout, " " ) );
    cout<<endl;
 
	//Inverser le tableau
   reverse( cost, cost + 4 );
 
   copy( cost, cost + 4,ostream_iterator<double>( cout, " " ) );
    cout<<endl;
   return 0;
 
}

No comments yet.

Leave a Comment