Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <stdlib.h>
- #include <time.h>
- using namespace std;
- int deleteArrayItem(string*,int,int);
- int main()
- {
- string Lines[20];
- ifstream tFile;
- tFile.open("data.in");
- int i = 0,
- k = 0,
- randomNb;
- while (!tFile.eof())
- getline(tFile, Lines[k++]);
- tFile.close();
- for(; i < 10 ; i++ )
- {
- srand(time(NULL));
- randomNb = rand() % (k -1);
- cout << Lines[randomNb] << endl;
- k = deleteArrayItem(Lines, randomNb, k);
- }
- return 0;
- }
- int deleteArrayItem(string arrayToDelete[], int itemPos, int arrayLen)
- {
- for (int i = itemPos; i <= arrayLen; i++ )
- arrayToDelete[i] = arrayToDelete[i + 1];
- return arrayLen - 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement