Computer Science, asked by Vibaksingh3483, 1 year ago

Given an array of integers, find the pair of adjacent elements that has the largest difference and return that difference. Example for input array

Answers

Answered by utkarshmishra9819
2

Answer:

class prog {

int mai(int n){

int a[]=new int[n];

int c=a[1]-a[0],v=a[0],b=a[1];

for (int i=2;i<n;i++)

{

int q=a[i]-a[i-1];

if(q>c)

{c=q; v=a[i-1];b=a[i];}

}

System.out.println("the pair is"+v"+"and"+b);

return c;}}

Similar questions