Maximum difference between adjacent elements of list: Difference between revisions
Maximum difference between adjacent elements of list (view source)
Revision as of 13:42, 18 July 2021
, 2 years agoAdded XPL0 example.
No edit summary |
(Added XPL0 example.) |
||
Line 65:
8,1 ==> 7
done...
</pre>
=={{header|XPL0}}==
<lang XPL0>real List, Dist, MaxDist;
int I;
[List:= [2., -3., 0., 1., 1., -2.3, 0., 5.5, 8., 6., 2., 9., 11., 8., 1.];
MaxDist:= 0.;
for I:= 0 to 15-2 do
[Dist:= abs(List(I) - List(I+1));
if Dist > MaxDist then
MaxDist:= Dist;
];
RlOut(0, MaxDist);
]</lang>
{{out}}
<pre>
7.00000
</pre>
|