Guest User

Untitled

a guest
Mar 28th, 2013
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.09 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <time.h>
  6.  
  7. using namespace std;
  8.  
  9. int main(int argc, char *argv[]) {
  10.    
  11.     char ans;
  12.     do
  13.     {
  14.     int x=0, i, b, p;
  15.     string g[100];
  16.     string t;
  17.    
  18.    
  19.    
  20.     cout<<"Introduce the name of things you want to do and this program will \ngive you a random selection of 3 elements"
  21.     <<", this may be useful if \nyou're not sure about what to do.\n \nYou can introduce up to 100 things.\n"
  22.     <<"\nWhen done just type 'DONE' \n\n\n\n How many results would you like? (1-3)\n ";
  23.     cin>>p;
  24.    
  25.     if(p >= 3)
  26.     {
  27.         p = 3;
  28.     }
  29.     else if(p <= 1)
  30.     {
  31.         p = 1;
  32.     }
  33.  
  34.     for(i=0; i<100; i++)
  35.     {
  36.         cout<<"\n\nIntroduce the name of thing "<<i+1<<": ";
  37.         getline (cin,t);
  38.         if(t == "DONE")
  39.             break;
  40.         g[i]=t;
  41.         x=i + 1;
  42.     }
  43.  
  44.     srand ( time (NULL));
  45.    
  46.     cout<<"\n\n\n---------RESULTS---------\n";
  47.    
  48.  
  49.     for(int j=0; j<p; j++)
  50.     {
  51.         int lol = rand() % x;
  52.        
  53.         cout<<"\n Thing "<<j+1<<" : "<<g[lol]<<"\n";
  54.     }
  55.    
  56.     cout<<"\n\n Try again? y/n \n\n ";
  57.     cin>>ans;
  58.     cout<<"\n\n";
  59. }
  60. while (ans != 'n');
  61.  
  62.     system("PAUSE");
  63.     return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment