#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int arr[] ={-3,5,2,-2,1,0,-6,7,-8,2};
int n=10,min=arr[0],max=-32767 ;
for(int i=1;i<n;i++)
{
if(arr[i]<min)
{
min=arr[i];
continue;
}
if(arr[i]-min>max)
max=arr[i]-min;
}
cout<<"MAX DIFFERENCE IS :
"<<max;
getch();
}
No comments:
Post a Comment