Advertisement
Guest User

Savuś

a guest
Nov 21st, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.    int n,x,a;
  6.    cin >> n >> x;
  7.    int t[n];
  8.  
  9.    for (int i = 0; i < n; i++){
  10.         cin >> t[i];
  11.    }
  12.    a = 0;
  13.     while(t[a]!=x || a>n)
  14.         if (t[a]==x)
  15.             cout << a+1 << " ";
  16.         else
  17.             a++;
  18.  
  19.    a = n;
  20.    while(t[a]!=x || a<=0)
  21.         if (t[a]==x)
  22.             cout << a+1 ;
  23.         else
  24.             a--;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement