Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "header.h"
- using namespace std;
- int VAL_CAUTATA;
- char intreaba(int val)
- {
- if(val<VAL_CAUTATA)
- return '<';
- else if(val==VAL_CAUTATA)
- return '=';
- else
- return '>';
- }
- void raspunde(int val)
- {
- if(val==VAL_CAUTATA)
- cout<<"BRAVO! Ai gasit numarul ascuns";
- else
- cout<<"N-ai orizont";
- }
- int main()
- {
- cin>>VAL_CAUTATA;
- gaseste();
- return 0;
- }
- void gaseste();
- void raspunde(int);
- char intreaba(int);
- #include <bits/stdc++.h>
- #include "header.h"
- using namespace std;
- void gaseste()
- {
- int r=0,pas=1<<30;
- char c;
- while(pas)
- {
- c=intreaba(r+pas);
- if(c=='<')
- r+=pas;
- else if(c=='=')
- {
- raspunde(r+pas);
- exit(0);
- }
- pas/=2;
- }
- raspunde(r);
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement