Advertisement
sherry_ahmos

Untitled

Dec 17th, 2021
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <sstream>
  3. #include <cstdlib>
  4. using namespace std;
  5. void sherry()
  6. {
  7. #ifndef ONLINE_JUDGE
  8.     freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  9. #endif
  10. }
  11. int main()
  12. {
  13.     sherry();
  14.     long long x, a, flag = 1;
  15.     cin >> x;
  16.     long long arr[x];
  17.     for (int i = 0; i < x; i++)
  18.     {
  19.         cin >> arr[i];
  20.     }
  21.     cin >> a;
  22.     for (int j = 0; j < x; j++)
  23.     {
  24.         if ((arr[j] == a) && (flag == 1))
  25.         {
  26.             cout << j;
  27.             flag = 0;
  28.         }
  29.     }
  30.     if (flag)
  31.     {
  32.         cout << "-1";
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement