|
-
August 8th, 2009, 07:34 PM
#1
Help me with this runtime error
I have been trying to make a memory game and I need help with this runtime error. Here is the code, read after the code and I will describe the runtime error.
#include "stdafx.h"
#include "Windows.h"
#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <conio.h>
#include <winbase.h>
#include <sstream>
#include <cstdlib>
#include <ctime>
using namespace std;
enum Colors { blue=1, green, cyan, red, purple, yellow, white, grey, dgrey, hblue, hgreen, hred, hpurple, hyellow, hwhite };
int Easy();
int Normal();
int Hard ();
int Insane();
int main()
{
string Difficulty;
cout << "Hello, this is a memory testing game, this game will generate different numbers in mixed numbers and they will get harder and harder as you go. If you miss to many the game will take you back to the difficulty selector. \n";
cout << "Please select your difficulty: Easy, Normal, Hard, and INSANE. Just type the \n name of the difficulty. \n";
cin >> Difficulty;
if (Difficulty == "easy" || Difficulty == "Easy" || Difficulty == "EASY")
{
Easy();
}
if (Difficulty == "normal" || Difficulty == "Normal" || Difficulty == "NORMAL")
{
Normal();
}
if (Difficulty == "hard" || Difficulty == "Hard" || Difficulty == "HARD")
{
Hard();
}
if (Difficulty == "insane" || Difficulty == "Insane" || Difficulty == "INSANE")
{
Insane();
}
char f;
cin >> f;
return 0;
}
int Easy()
{
system("COLOR 90");
int RanInt1;
int RanInt2;
int RanInt3;
int RanInt4;
int RanInt5;
int RanInt6;
int RanInt7;
int RanInt8;
int RanInt9;
int RanInt10;
int RanInt11;
int RanInt12;
int guess;
{
// Level one Questions
srand((unsigned)time(0));
for(int index=0; index<20; index++)
RanInt1 = (rand()%10)+1;
RanInt2 = (rand()%10)+2;
RanInt3 = (rand()%10)+3;
cout << "You have chosen easy mode.\n The test will begin now. \n \n";
cout << "These are level one questions. \n \n";
cout << "1. Remember this number:" << RanInt1 << endl;
system("pause");
system("cls");
cout << "What was the number? \n";
cin >> guess;
system("cls");
if (guess == RanInt1)
{
cout << "You remembered the number right! \n";
system("pause");
system("cls");
}
if (!(guess==RanInt1))
{
cout << "You guessed the number wrong!\n";
system("pause");
system("cls");
main();
}
cout << "2. NOTE: Remember to use the commas where the program tells you too. \n Remember these numbers in there order:" << RanInt1 << "," << RanInt2 << endl;
system("pause");
system("cls");
cout << "What were the numbers? \n";
cin >> guess;
system("cls");
if (guess == RanInt1 && RanInt2)
{
cout << "You remembered the numbers right!!! \n";
system("pause");
system("cls");
}
if (!(guess == RanInt1 && RanInt2))
{
cout << "You guessed the numbers wrong! Please try again. \n";
system("pause");
system("cls");
main();
}
}
{
// Level two questions
srand((unsigned)time(0));
for(int index=0; index<25; index++)
RanInt1 = (rand()%10)+1;
RanInt2 = (rand()%10)+2;
RanInt3 = (rand()%10)+3;
cout << "You are now on level two questions. Good luck! \n \n";
cout << "NOTE:Remember to use commas where the program tells you too! \n. Remember these numbers:" << RanInt3 << "," << RanInt2 << endl;
system("pause");
system("cls");
cout << "What was the number? \n";
system("cls");
cin >> guess;
if ( guess == RanInt3 && RanInt2 )
{
cout << "You remembered the numbers right!";
system("pause");
}
if (!(guess == RanInt3 && RanInt2))
{
cout << "You guessed the numbers wrong! Please try again\n";
system("pause");
main();
}
}
return 0;
}
int Normal()
{
system("cls");
cout << "You have chosen normal mode. This difficulty is recommended for people with an average IQ.\n";
cout << "These are level one questions.\n";
return 0;
}
int Hard()
{
system("cls");
cout << "You have chosen hard mode. This difficulty is recommended for people with an above average IQ.\n";
cout << " These are level one questions.\n";
return 0;
}
int Insane()
{
system("cls");
cout << "You have chosen insane mode. You are crazy.\n";
cout << " These are level one questions. Good Luck.\n";
return 0;
}
If you were to take my code and compile it and play it in easy mode you will notice that once you get to level 2 questions it won't let you enter the numbers and it tells you that you have guessed it wrong and then closes. I need help with this, I have NO idea what the problem could be.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|