# Answer to Question #27751 in C++ for bharat

Question #27751
Integer V lies strictly between integers U and W if U &lt; V &lt; W or if U &gt; V &gt; W. A non-empty zero-indexed array A consisting of N integers is given. A pair of indices (P, Q) where 0 &le; P &lt; Q &lt; N is said to have adjacent values if no value in the array lies strictly between values A[P] and A[Q]. For example, in array A such that A = 0 A = 3 A = 3 A = 7 A = 5 A = 3 A = 11 A = 1 the following pairs of indices have adjacent values: (0, 7), (1, 2), (1, 4), (1, 5), (1, 7), (2, 4), (2, 5), (2, 7), (3, 4), (3, 6), (4, 5), (5, 7).
1
2013-04-09T10:38:22-0400
#include <stdio.h>
#include <cstdlib>
#include <iostream>

using namespace std;

int main ()
{
int n;
scanf("%d", &n);
int *a = new int[n];
for (int i = 0; i < n; i++)
& scanf("%d", &a[i]);
for (int i = 0; i < n; i++) {
& int low_bound = i;
& for (int j = 0; j < n; j++) {
if (a[j] > a[i] && (low_bound == i || a[low_bound] > a[j])) {
low_bound = j;
}
& }
& if (low_bound != i) {
for (int j = 0; j < n; j++) {
if (a[j] == a[low_bound] || (a[j] == a[i] && i < j)) {
& printf("(%d, %d)\n", min(i, j), max(i, j));
}
}
& }
}
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Assignment Expert
06.11.18, 14:55

Dear POORNACHANDRAN S
is no guarantee of answering certain question but we are doing our best. And if answer
is published it means it was attentively checked by experts. You can try it yourself by
publishing your question. Although if you have serious assignment that requires large amount
of work and hence cannot be done for free you can submit it as assignment and our
experts will surely assist you.

POORNACHANDRAN S
05.11.18, 17:41

CAN U GIVE ME THE C CODE FOR THE SAME QUESTION

Assignment Expert
17.06.13, 15:57

If you really liked our service please press like-button beside answer field. Thank you!

Rishi
17.06.13, 02:36