Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- cout.flush();
- int n;
- cin >> n;
- int arr[n];
- int res=0;
- for (int i=0; i<n; i++)
- {
- cout << "? " << i+1 << endl;
- cin >> arr[i];
- if (arr[i] == i+1)
- {
- res = i;
- goto printl;
- }
- }
- printl: cout << "! " << res << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement