Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.06 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <cstdlib>
  4. #include <ctime>
  5. #include <fstream>
  6. #include <algorithm>
  7.  
  8. using namespace std;
  9.  
  10. typedef vector <unsigned> CVUint;
  11.  
  12. void AffichVInt (const vector <int> & VInt) {
  13.     for (unsigned i = 0; i < VInt.size(); ++i){
  14.         cout << VInt[i] << endl;
  15.     }
  16. }
  17.  
  18. template <typename T>
  19. void AffichVector (const vector <T> & V){
  20.     for (unsigned i = 0; i < V.size(); ++i){
  21.         cout << V[i] << endl;
  22.     }
  23. }
  24.  
  25. template <typename T>
  26. void ExtractionsGenerique (T & Val) {
  27.     while (cin >> Val){
  28.         cout << Val << endl;
  29.     }
  30. }
  31.  
  32. template <typename T>
  33. bool TestSiFichierExists (T & stream){
  34.     for (unsigned test = 0; test != 5 && !stream.is_open(); ++test){
  35.         cout << "Entrez le nom du fichier : ";
  36.         string filename;
  37.         cin >> filename;
  38.         stream.open(filename);
  39.     }
  40.     if (!stream.is_open()){
  41.         cout << "Nombre de tentative depasser ! " << endl;
  42.         exit(1);
  43.     }
  44. }
  45.  
  46. /*template <typename T>
  47. void SelectSort (vector<T> & VUint) {
  48.     for (typename vector<T>::iterator it(VUint.begin()); it != VUint.end(); ++it){
  49.         typename vector<T>::iterator min_it = min_element(it, VUint.end());
  50.         for (typename vector<T>::iterator it2 = it + 1 ; it2 != VUint.end(); ++it2){
  51.             if (*it2 < *min_it){
  52.                 *min_it = *it2;
  53.             }
  54.         }
  55.         if (*min_it != *it){
  56.             swap(*it, *min_it);
  57.         }
  58.     }
  59. }
  60. */
  61. template <typename T>
  62. void SelectSort (vector<T> & VUint) {
  63.     for (typename vector<T>::iterator it(VUint.begin()); it != VUint.end(); ++it){
  64.         typename vector<T>::iterator min_it = min_element(it, VUint.end());
  65.         if (min_it != it){
  66.             swap(*it, *min_it);
  67.         }
  68.     }
  69. }
  70.  
  71. int main(int argc, char *argv[])
  72. {
  73.     /*vector <int> v(5);
  74.     for (unsigned i = 0; i < 5; ++i){
  75.         v[i] = i;
  76.     }
  77.     AffichVector(v);
  78.     */
  79.  
  80.     /*string s;
  81.     TestSiFichierExists(s);
  82.     cout << s;
  83.     */
  84.  
  85.     /*ifstream v;
  86.     TestSiFichierExists(v);
  87.     */
  88.  
  89.  
  90.     return 0;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement