Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <cstdlib>
- #include <ctime>
- #include <fstream>
- #include <algorithm>
- using namespace std;
- typedef vector <unsigned> CVUint;
- void AffichVInt (const vector <int> & VInt) {
- for (unsigned i = 0; i < VInt.size(); ++i){
- cout << VInt[i] << endl;
- }
- }
- template <typename T>
- void AffichVector (const vector <T> & V){
- for (unsigned i = 0; i < V.size(); ++i){
- cout << V[i] << endl;
- }
- }
- template <typename T>
- void ExtractionsGenerique (T & Val) {
- while (cin >> Val){
- cout << Val << endl;
- }
- }
- template <typename T>
- bool TestSiFichierExists (T & stream){
- for (unsigned test = 0; test != 5 && !stream.is_open(); ++test){
- cout << "Entrez le nom du fichier : ";
- string filename;
- cin >> filename;
- stream.open(filename);
- }
- if (!stream.is_open()){
- cout << "Nombre de tentative depasser ! " << endl;
- exit(1);
- }
- }
- /*template <typename T>
- void SelectSort (vector<T> & VUint) {
- for (typename vector<T>::iterator it(VUint.begin()); it != VUint.end(); ++it){
- typename vector<T>::iterator min_it = min_element(it, VUint.end());
- for (typename vector<T>::iterator it2 = it + 1 ; it2 != VUint.end(); ++it2){
- if (*it2 < *min_it){
- *min_it = *it2;
- }
- }
- if (*min_it != *it){
- swap(*it, *min_it);
- }
- }
- }
- */
- template <typename T>
- void SelectSort (vector<T> & VUint) {
- for (typename vector<T>::iterator it(VUint.begin()); it != VUint.end(); ++it){
- typename vector<T>::iterator min_it = min_element(it, VUint.end());
- if (min_it != it){
- swap(*it, *min_it);
- }
- }
- }
- int main(int argc, char *argv[])
- {
- /*vector <int> v(5);
- for (unsigned i = 0; i < 5; ++i){
- v[i] = i;
- }
- AffichVector(v);
- */
- /*string s;
- TestSiFichierExists(s);
- cout << s;
- */
- /*ifstream v;
- TestSiFichierExists(v);
- */
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement