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