Shoelace formula for polygonal area: Difference between revisions

Line 14:
Show the answer here, on this page.
<br><br>
 
=={{header|360 Assembly}}==
<lang 360asm>* SHOELACE 25/02/2019
SHOELACE CSECT
USING SHOELACE,R15 base register
MVC SUPS(8),POINTS x(nt+1)=x(1); y(nt+1)=y(1)
LA R9,0 area=0
LA R7,POINTS @x(1)
LA R6,NT do i=1 to nt
LOOP L R3,0(R7) x(i)
M R2,12(R7) *y(i+1)
L R5,8(R7) x(i+1)
M R4,4(R7) *y(i)
SR R3,R5 x(i)*y(i+1)-x(i+1)*y(i)
AR R9,R3 area=area+x(i)*y(i+1)-x(i+1)*y(i)
LA R7,8(R7) @x(i++)
BCT R6,LOOP enddo
LPR R9,R9 area=abs(area)
SRA R9,1 area=area/2
XDECO R9,PG edit area
XPRNT PG,L'PG print area
BR R14 return to caller
NT EQU (SUPS-POINTS)/8 nt number of points
POINTS DC F'3',F'4',F'5',F'11',F'12',F'8',F'9',F'5',F'5',F'6'
SUPS DS 2F x(nt+1),y(nt+1)
PG DC CL12' ' buffer
REGEQU
END SHOELACE</lang>
{{out}}
<pre>
30
</pre>
 
=={{header|ALGOL 68}}==
Line 50 ⟶ 82:
30.00
</pre>
 
=={{header|C}}==
Reads the points from a file whose name is supplied via the command line, prints out usage if invoked incorrectly.
1,392

edits