allia

чет не работает

Sep 19th, 2020
976
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.   cout.flush();
  7.  int n;
  8.  cin >> n;
  9.  
  10. int arr[n];
  11. int res=0;
  12.  
  13. for (int i=0; i<n; i++)
  14. {
  15.   cout << "? " << i+1 << endl;
  16.   cin >> arr[i];
  17.   if (arr[i] == i+1)
  18.   {
  19.     res = i;
  20.     goto printl;
  21.   }
  22. }
  23. printl: cout << "! " << res << endl;  
  24. }
  25.  
RAW Paste Data