Maximum difference between adjacent elements of list: Difference between revisions
Content added Content deleted
No edit summary |
(Maximum difference between adjacent elements of list in FreeBASIC) |
||
Line 418: | Line 418: | ||
idx : 12 values 2.0000000000000000E+000 9.0000000000000000E+000 |
idx : 12 values 2.0000000000000000E+000 9.0000000000000000E+000 |
||
idx : 15 values 1.0000000000000000E+001 3.0000000000000000E+000 </pre> |
idx : 15 values 1.0000000000000000E+001 3.0000000000000000E+000 </pre> |
||
=={{header|FreeBASIC}}== |
|||
<lang freebasic>Dim As Single Dist, MaxDist = 0 |
|||
Dim As Single List(16) => {1., 8., 2., -3., 0., 1., 1., -2.3, 0., 5.5, 8., 6., 2., 9., 11., 10., 3.} |
|||
Print !"Maximum difference between adjacent elements of list is:" |
|||
For i As Integer = 0 To Ubound(List) |
|||
Dist = Abs(List(i) - List(i+1)) |
|||
If Dist > MaxDist Then MaxDist = Dist |
|||
Next i |
|||
For i As Integer = 0 To Ubound(List) |
|||
Dist = Abs(List(i) - List(i+1)) |
|||
If Dist = MaxDist Then Print List(i) & ", " & List(i+1) & " ==> " & MaxDist |
|||
Next i</lang> |
|||
=={{header|Go}}== |
=={{header|Go}}== |