1
0

Compare commits

..

No commits in common. "9fae0e4409ea9c95a641cb51f696187a4a9f70a2" and "a9b58871c077ecd1e161fd818b40dd406a3914d2" have entirely different histories.

View File

@ -1,6 +1,4 @@
#include <iostream> #include <iostream>
#include <random>
#include <chrono>
using string = std::string; using string = std::string;
void ignoreTillLineEnd(); void ignoreTillLineEnd();
@ -9,24 +7,15 @@ int promptfi(string);
int main() int main()
{ {
std::mt19937 rand {std::random_device{}()}; int nameC {promptfi("Enter the number of names:")};
std::uniform_int_distribution clamp {1, 10}; if (nameC < 1) {
string name {promptfs("Enter your name:")}; std::cout << "No names to be entered!\n";
std::cout << "Hello " << name << ", welcome to guess the number.\n"; return 1;
bool once {};
int num {clamp(rand)}, ent {};
do {
if (once) {
if (ent > num)
std::cout << "You Guessed Too High!\n";
else
std::cout << "You Guessed Too Low!\n";
}
ent = promptfi("Enter your guess:");
once = true;
} }
while (num != ent); string* names = new string[nameC];
std::cout << "Well done " << name << ", you guessed correctly!\n"; for (int i = 0; i < nameC; i++) names[i] = promptfs("Enter your name:");
std::cout << "I have " << nameC << " to say hello to!\n";
for (int i = 0; i < nameC; i++) std::cout << "Hello " << names[i] << ".\n";
return 0; return 0;
} }
@ -35,7 +24,7 @@ void ignoreTillLineEnd() {
} }
string promptfs(string msg) { string promptfs(string msg) {
bool once {}; bool once {false};
string toret {}; string toret {};
do { do {
if (once) { if (once) {
@ -53,7 +42,7 @@ string promptfs(string msg) {
} }
int promptfi(string msg) { int promptfi(string msg) {
bool once {}; bool once {false};
int toret {}; int toret {};
do { do {
if (once) { if (once) {