pmontgom@sdcrdcf.UUCP (Peter Montgomery) (03/12/84)
In "The Strange Power of FORTRAN: A Very Short Calendar Printing Program", ACM SIMSOFT Software Engineering Notes, Volume 9, No. 1, January, 1984, pp. 50-51, Hans Janssens presents a 19-line FORTRAN program for reading a year and printing its calendar. Here is a 10-line program. The program can be shortened to 9 lines by renaming its integer variables as I, J, K, L, M, N and removing the INTEGER statement. I believe the program complies with the 1977 standard (full language). I leave it to you to decipher it. CHARACTER DY*7, H(-10:1)*14 INTEGER D, M, Q, S, W, Y S(M)=5*(Y+M/9)/4-(Y+M/9)/100+(Y+M/9)/400 + (153*M+1516-16*(M/9))/5 DATA H,DY/'JANUARY','FEBRUARY','MARCH','APRIL','MAY','JUNE','JULY' *,'AUGUST','SEPTEMBER','OCTOBER','NOVEMBER','DECEMBER','MTWTFSS'/ READ *, Y PRINT'(1H1///4X,17HCOMPUTER CALENDAR,I5////4(//3(I8,A16)//7(3(A5, *1X,6I3.0)/)),1H1)',Y,((Y,H(M),M=Q-2,Q),((DY(D:D),(DIM (MOD(D+7*W- *MOD(S(M),7),15+S(M+1)-S(M)), 14),W=2,7),M=Q-2,Q),D=1,7),Q=-8,1,3) END -- Peter Montgomery {bli,blix,bmcg,burdvax,cbosgd,csun,hplabs,hughes,ihnp4,ihnss, netvax,orstcs,parallax,randvax,sdccsu3,sdcnet,sdcsvax,slant45, trw-unix,ucla-s,ucla-vax}!sdcrdcf!pmontgom