Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std ;
- typedef long long ll ;
- int main() {
- ios::sync_with_stdio(false) ; cout.tie(NULL) ; cin.tie(NULL) ;
- int n , pos = 0 ;
- bool p = false ;
- cin >> n ;
- ll arr[n] , num ;
- for (int i = 0; i < n; i++) cin >> arr[i] ;
- cin >> num ;
- for (int i = 0; i < n; i++) {
- if (arr[i] == num)
- p = true ;
- pos = i ;
- break;
- }
- if (p == true) cout << -1 ;
- else cout << pos ;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment