Skip to content

Instantly share code, notes, and snippets.

@cfr
Created July 6, 2013 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cfr/5940109 to your computer and use it in GitHub Desktop.
Save cfr/5940109 to your computer and use it in GitHub Desktop.
#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