1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
|
// 30Sseconds.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "time.h"
#include <vector>
#include <string>
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <limits>
#include <dos.h>
#include <stdio.h>
#include <conio.h>
using namespace std;
vector<string> persoon;
vector<string> ding;
vector<string> citaat;
vector<string> plaats;
void persoonF(){
string line;
ifstream myfile ("persoon.txt");
if (myfile.is_open())
{
while ( myfile.good() )
{
getline (myfile,line);
persoon.push_back(line);
}
myfile.close();
}
}
void plaatsF(){
string line;
ifstream myfile ("plaats.txt");
if (myfile.is_open())
{
while ( myfile.good() )
{
getline (myfile,line);
plaats.push_back(line);
}
myfile.close();
}
}
void citaatF(){
string line;
ifstream myfile ("citaat.txt");
if (myfile.is_open())
{
while ( myfile.good() )
{
getline (myfile,line);
citaat.push_back(line);
}
myfile.close();
}
}
void dingF(){
string line;
ifstream myfile ("ding.txt");
if (myfile.is_open())
{
while ( myfile.good() )
{
getline (myfile,line);
ding.push_back(line);
}
myfile.close();
}
}
string willekeurig(int will)
{
string a;
while(a.size() == 0){
if(will <3)
{if(persoon.size() != 0)
{
int random_integer = rand()%persoon.size();
a = persoon[random_integer];
persoon.erase (persoon.begin()+random_integer);
}}
if(will < 6 && will>=3)
{
if(ding.size() != 0)
{
int random_integer = rand()%ding.size();
a = ding[random_integer];
ding.erase (ding.begin()+random_integer);
}
}
if(will<8 && will>=6)
{
if(citaat.size() != 0)
{
int random_integer = rand()%citaat.size();
a = citaat[random_integer];
citaat.erase (citaat.begin()+random_integer);
}
}
if(will < 10 && will >=8)
{
if(plaats.size() != 0)
{
int random_integer = rand()%plaats.size();
a = plaats[random_integer];
plaats.erase (plaats.begin()+random_integer);
}
}
}
return a;
}
void woord(){
srand(time(NULL));
int will2 = rand() % 10;
cout << "\n " << willekeurig(will2);
}
void Delay(float milliSeconds)
{
const float clk_strt = float(clock());
while( clock() - clk_strt < milliSeconds )
continue;
}
int _tmain(int argc, _TCHAR* argv[])
{
persoonF();
plaatsF();
citaatF();
dingF();
srand(time(0));
int will, will1, will2, will3, will4, will5, will6;
while(true){
cout << "\n >>>>>>>Druk op een knop om door te gaan<<<<<<<";
cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
woord();
Delay(50);
woord();
Delay(50);
woord();
Delay(50);
woord();
Delay(50);
woord();
}
return 0;
}
|