Maximum difference between adjacent elements of list: Difference between revisions

Content deleted Content added
CalmoSoft (talk | contribs)
No edit summary
Loren (talk | contribs)
→‎{{header|XPL0}}: Revised for new requirements.
Line 80:
<lang XPL0>real List, Dist, MaxDist;
int I;
[List:= [1., 8., 2., -3., 0., 1., 1., -2.3, 0., 5.5, 8., 6., 2., 9., 11., 810., 13.];
MaxDist:= 0.;
for I:= 0 to 1517-2 do
[Dist:= abs(List(I) - List(I+1));
if Dist > MaxDist then
MaxDist:= Dist;
];
RlOutFormat(01, MaxDist0);
for I:= 0 to 17-2 do
[Dist:= abs(List(I) - List(I+1));
if Dist = MaxDist then
[RlOut(0, List(I)); Text(0, ", "); RlOut(0, List(I+1));
Text(0, " ==> "); RlOut(0, MaxDist); CrLf(0);
];
];
]</lang>
 
{{out}}
<pre>
1, 8 ==> 7.00000
2, 9 ==> 7
10, 3 ==> 7
</pre>