main.cpp 923 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include <iostream>
  2. #include <string>
  3. #include <cstdlib>
  4. #include <ctime>
  5. using namespace std;
  6. string createWord()
  7. {
  8. # define VOYELLE 1
  9. int nbChr( rand() % 10 + 3 );
  10. string rep("");
  11. for ( int i(0); i < nbChr; i++ )
  12. {
  13. if ( rand() % 2 == VOYELLE )
  14. rep += "aeiouy"[rand() % 6];
  15. else
  16. rep += "bcdfghjklmnpqrstvwxz"[rand() % 20];
  17. }
  18. return rep;
  19. }
  20. int main()
  21. {
  22. srand( time(0) );
  23. cout << "Pointeurs sur tableau !" << endl;
  24. string* tab(0x0);
  25. int in;
  26. cout << "Le tableau est déjà créé mais vous pouvez choisir sa taille !" << endl;
  27. cin >> in;
  28. cout << endl << endl;
  29. const int mySize(in);
  30. tab = new string[mySize];
  31. for ( int i(0); i < mySize; i++ ){
  32. tab[i] = createWord();
  33. }
  34. for ( int i(0); i < mySize; i++ ){
  35. cout << i << " : " << tab[i] << endl;
  36. }
  37. //delete tab;
  38. return 0;
  39. }