|
| 1 | +#include <iostream> |
| 2 | +#include <cstdlib> // For rand() and srand() |
| 3 | +#include <ctime> // For time() |
| 4 | +#include <string> |
| 5 | + |
| 6 | +using namespace std; |
| 7 | + |
| 8 | +void showEasterEgg() { |
| 9 | + cout << "\n[!] EASTER EGG ACTIVATED: THE ZEN MODE" << endl; |
| 10 | + cout << "Inspired by the Word 1.1a secret found 29 years later." << endl; |
| 11 | + cout << "EiJackGH Lab - Saying YES in 2026." << endl; |
| 12 | + cout << "========================================" << endl; |
| 13 | +} |
| 14 | + |
| 15 | +int main() { |
| 16 | + // Seed the randomizer |
| 17 | + srand(static_cast<unsigned int>(time(0))); |
| 18 | + |
| 19 | + int secretNumber = rand() % 100 + 1; |
| 20 | + string input; |
| 21 | + int guess = 0; |
| 22 | + int attempts = 0; |
| 23 | + |
| 24 | + cout << "--- EI-JACK LAB: NUMBER GUESSER V1.0 ---" << endl; |
| 25 | + cout << "I'm thinking of a number between 1 and 100." << endl; |
| 26 | + cout << "(Hint: Type 'zen' to see the credits)" << endl << endl; |
| 27 | + |
| 28 | + while (guess != secretNumber) { |
| 29 | + cout << "Enter your guess: "; |
| 30 | + cin >> input; |
| 31 | + |
| 32 | + // Check for Easter Egg |
| 33 | + if (input == "zen" || input == "ZEN") { |
| 34 | + showEasterEgg(); |
| 35 | + continue; |
| 36 | + } |
| 37 | + |
| 38 | + // Convert string to integer for the game logic |
| 39 | + try { |
| 40 | + guess = stoi(input); |
| 41 | + } catch (...) { |
| 42 | + cout << "Invalid input. Please enter a number." << endl; |
| 43 | + continue; |
| 44 | + } |
| 45 | + |
| 46 | + attempts++; |
| 47 | + |
| 48 | + if (guess > secretNumber) { |
| 49 | + cout << ">>> Too high! Try again." << endl; |
| 50 | + } else if (guess < secretNumber) { |
| 51 | + cout << ">>> Too low! Try again." << endl; |
| 52 | + } else { |
| 53 | + cout << "\nCONGRATULATIONS!" << endl; |
| 54 | + cout << "You found it in " << attempts << " attempts." << endl; |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | + cout << "----------------------------------------" << endl; |
| 59 | + system("pause"); // Essential for Dev-C++ to keep the window open |
| 60 | + return 0; |
| 61 | +} |
0 commit comments