Created
July 6, 2013 14:41
-
-
Save cfr/5940109 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <iostream> | |
#include <cstdlib> | |
#include <ctime> | |
int main() | |
{ | |
std::vector<std::string> v; | |
v.push_back("Yes"); | |
v.push_back("Signs point to yes"); | |
v.push_back("It is certain"); | |
v.push_back("It is decidedly so"); | |
v.push_back("Without a doubt"); | |
v.push_back("Yes, definitely"); | |
v.push_back("You may rely on it"); | |
v.push_back("As I see it yes"); | |
// etc. | |
char q[0x100] = { 0 }; | |
while (true) { | |
std::srand(std::time(nullptr)); | |
int idx = rand() % v.size(); // this isn't perfect either, by the way | |
std::cout << "Ask a question:" << std::endl; | |
std::cin.getline(q, sizeof(q)); | |
if (std::string(q) == "exit") | |
break; | |
std::cout << v[idx] << std::endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment