Steefmaester

Sort pointer

Mar 24th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int array[] = { 23,-1,9999,0,4 };
  9.  
  10.     unsigned int array_size = 5;
  11.  
  12.     cout << "Tableau avant le tri : ";
  13.     for (int i = 0; i < array_size; i++)
  14.         cout << array[i] << " ";
  15.     cout << endl << endl;
  16.  
  17.     cout << "array = " << *array << endl;
  18.     cout << "array + array_size-1 = " << *(array + array_size-1) << endl;
  19.  
  20.     cout << "array + array_size = " << *(array + array_size) << endl;
  21.     cout << "end(array) " << *(end(array)) << endl<<endl;
  22.  
  23.  
  24.     //C#
  25.     sort(array, array + array_size);
  26.  
  27.     //C++11
  28.     //sort(begin(array), end(array));
  29.  
  30.     cout << "sort(array, array + array_size) = ";
  31.     for (int i = 0; i < array_size; i++)
  32.         cout << array[i] << " ";
  33.     cout << endl;
  34.  
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment