Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- int max = 100;
- int min = 0;
- int r;
- int i = 0;
- int middle;
- srand (time(NULL));
- r = rand() % (max - min + 1) + min;
- cout << "zagadano chislo: " << r << endl;
- do {
- middle = (max + min) / 2;
- cout << "(" << max << "+" << min << ")/2 = ";
- if (middle > r) {max = middle;}
- else if (middle < r) {min = middle;}
- cout << middle << endl;
- cin.get();
- i++;
- } while (middle != r);
- cout << "popitok: " << i;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement