Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <stdio.h>
- #include <time.h>
- #include <windows.h>
- using namespace std;
- int n = 25, level = 1, random = 0, guess = 0, guess_prev = 0;
- int grid[26], memory[26];
- bool ops = false;
- void Afisare()
- {
- cout << "--------------------------------------------------------------------\n";
- cout << " Memory Game \n";
- cout << "--------------------------------------------------------------------\n";
- cout << " Rules \n";
- cout << "--------------------------------------------------------------------\n";
- cout << " You can already see that there's a grid of numbers. When the level \n";
- cout << " begins some numbers will blink in a particular order which you'll \n";
- cout << " have to reproduce.\n";
- cout << "--------------------------------------------------------------------\n";
- cout << " Level: " << level << "\n ";
- for( int i=1 ; i<=n ; i++ )
- {
- if( i == random )
- cout << (char) 178 << " ";
- else
- {
- if( i < 10 )
- cout << i << " ";
- else
- cout << i << " ";
- }
- if( i%5 == 0 )
- cout << "\n ";
- }
- }
- void GenerateNumber()
- {
- srand(time(NULL));
- for( int i=1 ; i<=level ; i++ )
- {
- guess_prev = guess;
- do
- {
- random = rand()%n + 1;
- }
- while( guess != guess_prev );
- }
- }
- int main()
- {
- while(1)
- {
- for( int i=1 ; i<=level ; i++ )
- {
- GenerateNumber();
- memory[i] = random;
- Afisare();
- Sleep(2000);
- system("cls");
- }
- random = 0;
- Afisare();
- for( int i=1 ; i<=level ; i++ )
- {
- if( i>1 )
- cout << " Enter your guess(number pls): ";
- else
- cout << "Enter your guess(number pls): ";
- cin >> guess;
- if( guess != memory[i] )
- {
- system("cls");
- cout << "Ops :( You lost! ";
- ops = true;
- break;
- }
- Sleep(500);
- }
- if( ops || level == 10 )
- break;
- system("cls");
- cout <<" Congrats! You have beaten level " << level;
- Sleep(1000);
- system("cls");
- level++;
- }
- Sleep(10000);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement