Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- //http://pastebin.com/fudTGzMK
- void randomize()
- {
- srand(time(nullptr));
- rand();
- }
- int random(int min, int max)
- {
- int range = max - min + 1;
- return (double)rand() / RAND_MAX *
- range + min;
- }
- int main()
- {
- randomize();
- int cpuNumber = random(1, 100);
- for (int i = 1; i <= 10; i++)
- {
- cout << "Proba " << i << endl;
- int myNumber;
- cout << "Podaj liczbe" << endl;
- cin >> myNumber;
- if (myNumber > cpuNumber)
- {
- cout << "Za duzo" << endl;
- }
- else if (myNumber < cpuNumber)
- {
- cout << "Za malo" << endl;
- }
- else
- {
- cout << "Zgadles!!!" << endl;
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement