Zadatci sa slajdova

odluke_z5.cpp

Committer:
Paaranoja
Date:
2016-11-01
Revision:
0:ea32457dbd8b

File content as of revision 0:ea32457dbd8b:

#include <iostream>
#include <ctime>
#include <cstdlib>

using namespace std;

int main (){

    int a = 0;
    int b = 9;
    int c=10;
    int rnd;
    srand((unsigned) time (NULL));
    //cout << RAND_MAX;
    rnd = rand() % (b-a+1)+a;
    cout << rnd<< endl<<endl;
    while (c >= 10 || c < 0){
        cout<<"Pogodi koji je broj od 0 do 9 zamislio ovaj kompjutor?" << endl;
        cin >> c;
    }

    if (rnd == c){
        cout<< "Pogodak";
    } else if (abs(rnd-c) <=2){
        cout<< "Blizu!";
    } else {
        cout<< "Ni blizu!!";
    }
}