# PROBLEM LINK:Contest Page | CodeChef

Author: Setter’s name

Tester: Tester’s name

Editorialist: Editorialist’s name

DIFFICULTY : EASY

Nill

# PROBLEM:

Shambu’s Chittappan Tracker has a new update. According to this update from a group of people it can search its neighbours.Each person is given an unique numerical code. Try to make the source code for the application.

# QUICK EXPLANATION:

The array is traversed to find the array element before and after the required element

# EXPLANATION:

The array arr and the variable item are inserted. Until the array’s length is reached the array element (arr[i]) is compared with the item. If a match is found the values arr[i-1] and arr[i+1] are stored in variables n1 and n2 respectively.

# SOLUTIONS:

Setter's Solution

using namespace std;

int main() {

int n,arr[50],i,item,n1,n2;

cin>>n;

for(i=0;i<n;i++)

cin>>arr[i];

cin>>item;

for(i=0;i<n;i++)

{

if(arr[i]==item)

{

n1=arr[i-1]; n2 = arr[i+1];

}

}

cout<<n1<<"\n"<<n2;

return 0;

}

Tester's Solution

Same Person

Editorialist's Solution

Same Person