MyTripleX_Code

Here’s my tripleX Code for now.

#include <iostream>

// Golbal Var
int GolbalDiffcult = 1;
const int MaxDiffcult = 9;

// Some Main Text
void PrintProduction()
{
    std:: cout << "\n\nEpic Start Line 1 \n ";
}


// Main Game Func 
int PlayGame(int level)
{
    int CurentLevel = level;
    std:: cout << "...Hack In... Level " << CurentLevel << std::endl;
    std:: cout << "Enter Passcode...\n\n";
    
    
    int CodeA = rand() % 10 + 1;
    int CodeB = rand() % 10 + 1;
    int CodeC = rand() % 10 + 1;

    
    int CodeSum = CodeA + CodeB + CodeC;
    int CodeProduct = CodeA * CodeB * CodeC;
    
    std:: cout << std::endl;
    std:: cout << "+ There're 3 Number in Queue\n" ;
    std:: cout << "The Sum is "<< CodeSum << std:: endl;
    std:: cout << "The Mulitpy is " << CodeProduct << std:: endl;


    int PlayerGuessA, PlayerGuessB, PlayerGuessC; 
    std:: cout << "Enter Your Code (A B C )\n" ;
    std:: cin >> PlayerGuessA >> PlayerGuessB >> PlayerGuessC;

    int GuessSum = PlayerGuessA + PlayerGuessB + PlayerGuessC;
    int GuessProduct = PlayerGuessA * PlayerGuessB * PlayerGuessC;


    if( CodeSum == GuessSum && CodeProduct == GuessProduct)
    {
        std:: cout << "Great Code Accpected \n";
        ++GolbalDiffcult;
    }
    else
    {
        std:: cout << "Wrong PassCode \n";
        GolbalDiffcult = CurentLevel;
    }

    return 0;

}


// Main Logic
int main()
{
    while(GolbalDiffcult <= MaxDiffcult)
    {
        PrintProduction();
        PlayGame(GolbalDiffcult);
    }


    std:: cout << "You Win Agent";


    return 0;
}
1 Like

Hi and welcome to the community.

Thanks for sharing. I hope you’re enjoying the course.

Privacy & Terms