All pastes #884142 Raw Edit

Guess A Number Code C++

public cpp v1 · immutable
#884142 ·published 2008-01-30 08:35 UTC
rendered paste body
#include <iostream>#include <stdlib.h>#include <time.h>#include <string>using namespace std;void Start ();void GetResults ();int  i, j, life, maxrand, a, d , l;int result;char c;voidStart (){     i = 0; // guess by user     j = 0; //secret number     life = 0; // lives     maxrand = 6; // maximum random number     cout << "Select difficulty:\n";     cout << "1 : Easy (0-15)\n";     cout << "2 : Medium (0-30)\n";     cout << "3 : Difficult (0-50)\n";     cout << "4 : Extreme (0-1000)\n";     cout << "5 : Custom Number\n";     cout << "6 : Custom Number + Custom Lives \n";     cout << "7 : Random Number + 10 lives \n";     cout << "or type another key to quit\n";           c = 30;     cin >> c;     cout << "\n";     switch (c)     {        case '1' : maxrand = 15;        l = 5;        break;        case '2' : maxrand = 30;        l = 5;             break;        case '3' : maxrand = 50;        l = 5;        break;        case '4' : maxrand = 1000;        l = 5;        break;        case '5' : maxrand = a;            cout << "Put In the maximum number You Would Like: \n";        cin >> d;        maxrand = d;        l = 5;           break;        case '6' : maxrand = a;            cout << "Put In the maximum number You Would Like: \n";        cin >> d;        maxrand = d;        cout << "please enter the number of lives \n";        cin >> l;        case '7' : maxrand =  rand();        cout << "the maximum number is  ";        cout << maxrand;        cout << "\n";        l = 10;                       break;        default : exit(0);        break;     }     life = l;             srand( (unsigned)time( NULL ) );     j = rand() % maxrand;     GetResults();}voidGetResults (){     if (life <= 0)            {        cout << "Try Again\n\n";        cout << "the number was\n";        cout << j;        cout << "\n\n\n" ;                        Start();     }     cout << "Type a number: \n";          cin >> i;         if ((i>maxrand) || (i<0))      {        cout << "\n\n Error : Number not between 0 and \n" << maxrand;        GetResults();     }     if (i == j)     {        cout << "Congratulations You Win\n\n";         Start();     }     else if (i>j)     {        cout << "Too High\n\n\n";        life = life - 1;         cout << "Number of remaining life: " << life << "\n\n";        GetResults();     }     else if (i<j)     {        cout << "Too Low\n\n\n";        life = life - 1;        cout << "Number of remaining life:\n" << life << "\n\n";        GetResults();     }}intmain (){     cout << "** Higher Or Lower **\n";     cout << "The goal of this game is to guess my secret number in 5 guesses\n";     cout << "I will then tell you if your guess is too big of too small compared\n to my secret number\n\n";     Start();     return 0;}