#include <iostream>
// simple guess the number game.
using namespace std;
void Answer()
{
cout << "WOW. You actually Got it right? Computer Malfuntion!\n\n \a\a\a\a";
}
int main()
{
cout << "Guess the number BETA. \n\nDifficulty = to the max (Prototype At the moment.)\n\nNote: the number will keep adding up everytime you fail!\nAlso there is a extreme bug when user inputs a character. BEWARE\n" << endl;
char error[1];
int secretNumber;
double userGuess;
secretNumber = 34;
loop:
cout << "\n\nGuess the number:\n\n";
cin >> userGuess;
if (userGuess > secretNumber)
{
cout << "***************\n!!!TOO BIG!!! Try again!\n***************";
++secretNumber;
goto loop;
}
if(userGuess < secretNumber)
{
cout << "****************\n!!!TOO SMALL!!! Try Again\n****************";
++secretNumber;
goto loop;
}
else
{
Answer();
}
return 0;
}
#include <iostream>
#include <windows.h>
#include <math.h>
#include <string.h>
#include <conio.h>
// simple guess the number game.
using namespace std;
void Answer()
{
cout << "WOW. You actually Got it right? Computer Malfuntion!\n\n \a\a\a\a";
Sleep(1000);
return;
}
//ignore this part, it just determines wether the input is a number or not!
bool stringToShort(string valThisStr,short& copyToMeIfYouCan)
{
copyToMeIfYouCan = 0;
for(char index=0;index<valThisStr.length();index++)
{
if(index!=0)
copyToMeIfYouCan*=10;
if(isdigit( (((int)valThisStr[index])-4 ))
{
copyToMeIfYouCan = 0;
return false;
}
copyToMeIfYouCan += (short)valThisStr[index]-48;
}
return true;
}
//^^^^^^ Ignore this part ^^^^^^^^
int main()
{
cout << "Guess the number BETA. \n\nDifficulty = to the max (Prototype At the moment.)\n\nNote: the number will keep adding up everytime you fail!\nAlso there is a extreme bug when user inputs a character. BEWARE\n" << endl;
short twoDigitNumber =0;
short userGuess =0;
string input ="";
srand ((unsigned)time(NULL)); // inistialize random value generator
twoDigitNumber = rand()%41; // random number from 0 to 40
cout<<endl;
system("PAUSE");
for(; // loop:
{
system("CLS");
cout << "\n\nGuess the number: ";
getline(cin,input);
//we want to convert short to char to compare, so we use (char) before variable
if(stringToShort(input,userGuess))//if the input is a number, play the game
{
if (userGuess>twoDigitNumber)
{
cout << "***************\n!!!TOO BIG!!! Try again!\n***************";
twoDigitNumber++;
Sleep(1000);
continue; // never use goto, cotinue starts the loop again
}
if (userGuess<twoDigitNumber)
{
cout << "****************\n!!!TOO SMALL!!! Try Again\n****************";
twoDigitNumber++;
Sleep(1000);
continue; //same as goto loop:
}
else
{
Answer();
return 0;
}
}
else
{
cout<<"\n\nYou did not enter a number!";
}
Sleep(1000);
}
}
Copyright © 2024, NextGenUpdate.
All Rights Reserved.