TP de C++
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

exercice6.cpp 645B

12345678910111213141516171819202122232425262728293031323334
  1. #include <iostream>
  2. #include <string>
  3. #include <list>
  4. #include <algorithm>
  5. using namespace std;
  6. int main(/*int argc, char const *argv[]*/)
  7. {
  8. list<string> liste;
  9. liste.push_back("Il");
  10. liste.push_back("fait");
  11. liste.push_back("beau");
  12. cout << "Avant : " << endl << endl;
  13. for(list<string>::iterator it=liste.begin(); it!=liste.end();it++){
  14. cout << *it << endl;
  15. }
  16. list<string>::iterator searcher=find(liste.begin(),liste.end(),"beau");
  17. liste.insert(searcher,"très");
  18. cout << endl << "Après : " << endl << endl;
  19. for(list<string>::iterator it2=liste.begin(); it2!=liste.end();it2++){
  20. cout << *it2 << endl;
  21. }
  22. return 0;
  23. }