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
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
English,
6 months ago
Social Sciences,
6 months ago
Computer Science,
1 year ago
Computer Science,
1 year ago
Math,
1 year ago