User:Deryck Chan/Cpp

From Wikipedia, the free encyclopedia

[edit] Hoi Hao Jung

#include <cstdlib>
#include <iostream>
#include <time.h>

using namespace std;

int main()
{
    int n, m, up, down, in;
    srand ( time(NULL) );
    m=(((rand()%rand())+(rand()%rand()))%98)+1;
    up=100;
    down=1;
    n=m;
    for (;;){
        cout << down << " to " << up << endl;
        cin >> in;
        if (in==n)
        {
                  cout << "BREAK!" << endl;
                  system ("Pause");
                  break;
        }
        else if (in%1!=0 || in>up || in<down){}
        else if (in<n)
        {
             down=in;
        }
        else if (in>n)
        {
             up=in;
        }    
    }    
    return 0;
}