Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <stdlib.h>
- #include <string.h>
- #include <time.h>
- using namespace std;
- int main(int argc, char *argv[]) {
- char ans;
- do
- {
- int x=0, i, b, p;
- string g[100];
- string t;
- cout<<"Introduce the name of things you want to do and this program will \ngive you a random selection of 3 elements"
- <<", this may be useful if \nyou're not sure about what to do.\n \nYou can introduce up to 100 things.\n"
- <<"\nWhen done just type 'DONE' \n\n\n\n How many results would you like? (1-3)\n ";
- cin>>p;
- if(p >= 3)
- {
- p = 3;
- }
- else if(p <= 1)
- {
- p = 1;
- }
- for(i=0; i<100; i++)
- {
- cout<<"\n\nIntroduce the name of thing "<<i+1<<": ";
- getline (cin,t);
- if(t == "DONE")
- break;
- g[i]=t;
- x=i + 1;
- }
- srand ( time (NULL));
- cout<<"\n\n\n---------RESULTS---------\n";
- for(int j=0; j<p; j++)
- {
- int lol = rand() % x;
- cout<<"\n Thing "<<j+1<<" : "<<g[lol]<<"\n";
- }
- cout<<"\n\n Try again? y/n \n\n ";
- cin>>ans;
- cout<<"\n\n";
- }
- while (ans != 'n');
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment