Advertisement
Andrei11114

for Londonezul

May 8th, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4.  
  5. #include <stdlib.h>
  6. #include <time.h>
  7.  
  8. using namespace std;
  9.  
  10. int deleteArrayItem(string*,int,int);
  11.  
  12. int main()
  13. {
  14.  
  15.  
  16.     string Lines[20];
  17.     ifstream tFile;
  18.  
  19.     tFile.open("data.in");
  20.     int i = 0,
  21.         k = 0,
  22.         randomNb;
  23.  
  24.     while (!tFile.eof())
  25.         getline(tFile, Lines[k++]);
  26.  
  27.     tFile.close();
  28.  
  29.     for(; i < 10 ; i++ )
  30.     {
  31.         srand(time(NULL));
  32.         randomNb = rand() % (k -1);
  33.         cout << Lines[randomNb] << endl;
  34.         k = deleteArrayItem(Lines, randomNb, k);
  35.     }
  36.     return 0;
  37. }
  38.  
  39. int deleteArrayItem(string arrayToDelete[], int itemPos, int arrayLen)
  40. {
  41.     for (int i = itemPos; i <= arrayLen; i++ )
  42.         arrayToDelete[i] = arrayToDelete[i + 1];
  43.     return arrayLen - 1;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement