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