part1c - END IF...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
PROGRAM part1c IMPLICIT NONE INTEGER::x1,y1,x2,y2,a,b,n WRITE(*,*)"Enter the coordinates of the first point:" READ(*,*)x1,y1 WRITE(*,*)"Enter the coordinates of the second point:" READ(*,*)x2,y2 a = x2-x1 IF (a<0)THEN WRITE(*,*)"Invalid coordinates for a were entered." STOP END IF b = y2-y1 IF(b<0)THEN WRITE(*,*)"Invalid coordinates for b were entered." STOP
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: END IF WRITE(*,'(A,I10,A,I2,A,I2,A,I2,A,I2,A)')&quot;There are &quot;,n(a,b),&quot; paths &amp; &amp;between (&quot;,x1,&quot; ,&quot;,y1,&quot; ) and (&quot;,x2,&quot; ,&quot;,y2,&quot; ).&quot; END PROGRAM RECURSIVE INTEGER FUNCTION n(a,b) RESULT(path) IMPLICIT NONE INTEGER, INTENT(IN)::a,b INTEGER::path IF(a==0 .OR. b==0)THEN path=1 ELSE path=n(a-1,b) + n(a,b-1) END IF END FUNCTION n...
View Full Document

Ask a homework question - tutors are online