goto label
and the conditional goto statement looks like this
if(expression)goto label
The language contains many other statements, but only the conditional
goto begins with "if(" and ends with ")goto label" where
label is an integer. All spaces are ignored within a Fortran IV
statement. For this problem, the "stop" statement, which halts execution,
appears only as the last line of the program.
Your job is to determine whether or not two Fortran programs are equivalent. They are equivalent if, for all possible inputs, they execute exactly the same sequence of statements, ignoring unconditional gotos and labels. By "the same sequence of statements" we mean statements that are textually identical, after spaces and labels are removed. You must assume that each conditional goto will be taken for some inputs and not taken for others. Unconditional gotos are, of course, always taken.
Your input consists of several couples of programs separated by a blank line. There is also a blank line between two consecutive couples. No input line exceeds 80 characters and no program contains more than 1000 lines. Each label used in a goto statement appears to the left of exactly one statment; no label is repeated. Output consists if a single line for each one of the input couples, stating either "The programs are equivalent." or "The programs are not equivalent."
read 6, i,k,j
99 if(i .lt. j)goto 33
goto 55
33 i=j
goto 99
55 k=j+1
stop
read6,i,k,j
if(i.lt.j)goto12345
77 k=j+1
goto5555
12345 i=j
if(i.lt.j)goto12345
goto77
88 goto88
5555 stop
read 6, i,k,j
99 if(i .lt. j)goto 33
goto 55
33 i=j
goto 99
55 k=j+2
stop
read6,i,k,j
if(i.lt.j)goto12345
77 k=j+1
goto5555
12345 i=j
if(i.lt.j)goto12345
goto77
5555 stop
The programs are equivalent. The programs are not equivalent.