💾 Archived View for gemini.spam.works › mirrors › textfiles › humor › COMPUTER › weirdpro.txt captured on 2022-07-17 at 02:38:13.

View Raw

More Information

⬅️ Previous capture (2022-06-12)

-=-=-=-=-=-=-


___________________________BORED-1.FOR_______________________________________

C       BORED BY PASCAL?
C       ================
C       PASCAL IS DESIGNED SO THAT YOU DON'T HAVE TO THINK
C       WHILE PROGRAMMING. THIS IS GOOD FOR BEGINNERS BUT WILL
C       BECOME A LITTLE BORING AFTER A WHILE.
C       THIS LITTLE PROGRAM WAS WRITTEN TO DEMONSTRATE A
C       NICE FEATURE OF FORTRAN: THE POSSIBILITY OF WRITING
C       I N T E R E S T I N G  CODE.
C       IF THIS PROGRAM WERE WRITTEN IN PASCAL, IT WOULD BE QUITE
C       BANAL AND EASILY UNDERSTANDABLE EVEN TO THE AVERAGE TLTH
C       MEMBER. THAT WOULD BE NO FUN, HOWEVER.
C
C       NOTE THE FOLLOWING NICETIES:
C       * THE ABSENCE OF SENSIBLE COMMENTS-REAL PROGRAMMERS UNDERSTAND
C         FORTRAN BETTER THAN ENGLISH!
C       * THE ARITHMETIC IF-STATEMENTS (ADDING NICE FLAVOUR TO
C         THE CODE)
C       * THE WONDERFULLY CONCISE VARIABLE NAMES
C       * THE H-FORMAT FOR ALPHANUMERIC OUTPUT ( A LIVING FOSSIL
C         FROM THE HAPPY DAYS OF THE PUNCHED CARD)
C       * THE NICE SPAGHETTI STRUCTURE - STRUCTURED PROGRAMMING
C         IS ONLY FOR AMATEURS AND OLD LADIES
C
C       A SMALL REWARD IS OFFERED TO ANYBODY ABLE TO SAY WHAT
C       THIS PROGRAM DOES (WITHOUT ACTUALLY RUNNING IT)
C       SEND YOUR ANSWERS TO  TOM A.CRONA,
C                             DEPARTMENT OF COMMUTER SCIENCE
C                             AND NUMERICAL SYNTHESIS,
C                             UNIVERSITY OF LUND
C
C       PLEASE NOTE THAT THIS PROGRAM IS NOT IN ANY WAY PATHOLOGICAL
C       BUT A PERFECTLY NORMAL EXAMPLE OF WHAT PROGRAMMING WAS LIKE
C       BACK IN THE GOLDEN DAYS WHEN COMPUTERS WERE COMPUTERS AND
C       PROGRAMMERS WERE PROGRAMMERS...


 10     WRITE (*,487)
        READ (*,*) N
        IF (N) 10,10,30
 30     I1=2
 97     I2=0
 60     J=MOD(N,I1)
        IF (J) 40,50,40
 50     I2=I2+1
        N=N/I1
        GOTO 60
 40     IF (I2-1) 70,80,90
 70     I1=I1+2
        IF (I1-4) 120,135,120
 135    I1=3
 120    IF (I1-N) 97,97,3
 3      WRITE (*,65)
        READ (*,*) I3
        IF (I3) 3,130,10
 130    STOP
 80     WRITE (*,855) I1
        GOTO 70
 90     WRITE (*,930) I1,I2
        GOTO 70
 487    FORMAT (8H NUMBER?/)
  65    FORMAT (20H CONTINUE? (1=Y,0=N)/)
 855    FORMAT (I5)
 930    FORMAT (I5,3H **,I5)

C       BE A CREATIVE PROGRAMMER - USE FORTRAN
C       (C) SFRGOD (The Society For Revival of the Good Old
C                   Days), Fortran section, 1984
        END

____________________________BORED-2.PAS_________________________________________

{   BORED BY PASCAL?    part 2
    ==========================
    In this degenerate age of the toy computer (by some weak souls
    called "personal computer" or something like that) everyone learns
    programming in kindergarten or at least in high school (if there's
    any difference between those school forms). For this activity, a
    language called BASIC is used almost exclusively. BASIC is rather
    like a small subset of FORTRAN with many of its good features
    amputated but with all of its drawbacks. Anyway, you can write
    all kinds of programs in BASIC, and since it (fortunately!) lacks
    any trace of structured constructs it promotes creative programming
    the same way FORTRAN does and you get programmers who THINK while
    they're programming.
    When these persons start a higher education, they are forced
    to write their programs in a "language" called Pascal and are
    thereby quickly converted into well-adapted quiche eaters without
    a trace of originality. This paper was written to point out a method
    of solving this problem.

    Actually, you don't have to learn Pascal at all - it's much easier
    to write your programs in BASIC and then translate them directly
    into Pascal. As an example, consider the following program. It was
    originally written in BASIC on a ZX80 (Yecch!) and then transformed
    into syntactically perfect Pascal during the pause between two
    lectures.
    Most Pascal addicts turn away in disgust when seeing the words
    GOTO and LABEL, but there's absolutely no reason to discriminate
    these constructs - after all they're a part of the language (if that's
    not too strong a word to use about Pascal). Why should any programmer
    reject what is good enough for the compiler? Besides, the GOTO was
    there first - structured programming is a much later (and unnecessary)
    addition.

    By following this recipe, the young, undestroyed programmers can
    continue writing their programs in BASIC, avoid learning more
    Pascal than absolutely necessary and at the same time satisfy the
    Pascal buffs of the university. }

PROGRAM NIM (INPUT,OUTPUT);
{(c) Tom A. Crona 1984}
LABEL 70,90,150,230,280,370,400,460,470,520,540,800,810,820;
VAR J,S1,D,E,H,R,K : INTEGER; { WHO NEEDS FANCY LONG VARIABLE NAMES?}
    A,B : ARRAY [0..3] OF INTEGER;
    C   : ARRAY [0..3,0..3] OF INTEGER;

FUNCTION MTH$RANDOM(VAR SEED:INTEGER):REAL; EXTERNAL;

    BEGIN
    WRITELN ('******* NIM *******');
    WRITELN ('I HOPE YOU KNOW THE RULES OF NIM.');
    WRITELN ('ANYWAY I''M NOT GOING TO RECITE THEM...');
    WRITELN ('ENTER RANDOM SEED');
    READ(S1);
 70:FOR D:=0 TO 3 DO
    A[D]:=TRUNC(MTH$RANDOM(S1)*15+1);
 90:FOR D:=0 TO 3 DO
    WRITELN (D+1,':',A[D]:2);
    IF A[0]+A[1]+A[2]+A[3]>0 THEN GOTO 150;
    WRITELN ('*I WON*');
    GOTO 540;
150:WRITELN ('WHICH PILE?');
    READ (D);
    IF (D<1) OR (D>4) THEN GOTO 800;
    WRITELN ('HOW MANY?');
    READ (E);
    IF (E<1) OR (E>A[D-1]) THEN GOTO 810;
    A[D-1]:=A[D-1]-E;
    D:=-1;
230:D:=D+1;
    IF D=4 THEN GOTO 460;
    FOR E:=0 TO 3 DO
    B[E]:=A[E];
280:B[D]:=B[D]-1;
    IF B[D]<0 THEN GOTO 230;
    FOR E:=0 TO 3 DO
    BEGIN
    H:=B[E];
    R:=16;
    FOR J:=0 TO 3 DO
    BEGIN
    C[J,E]:=0;
    R:=R DIV 2;
    IF H<R THEN GOTO 370;
    C[J,E]:=1;
    H:=H-R;
370:END;
    END;
    E:=-1;
400:E:=E+1;
    H:=C[E,0]+C[E,1]+C[E,2]+C[E,3];
    IF H MOD 2>0 THEN GOTO 280;
    IF E<3 THEN GOTO 400;
    A[D]:=B[D];
    GOTO 90;
460:D:=-1;
470:D:=D+1;
    IF D=4 THEN GOTO 520;
    IF A[D]=0 THEN GOTO 470;
    A[D]:=A[D]-TRUNC(MTH$RANDOM(S1)*A[D]+1);
    GOTO 90;
520:WRITELN ('YOU WON.');
540:WRITELN ('ENTER 1 IF YOU WISH TO CONTINUE, 0 OTHERWISE');
    READ (K);
    IF K=1 THEN GOTO 70;
    GOTO 820;
800:WRITELN ('THERE IS NO SUCH PILE, STUPID!!!');
    GOTO 150;
810:WRITELN ('TRYING TO CHEAT, EH?');
    GOTO 150;
820:END.

______________________________BORED-3.COB__________________________________



IDENTIFICATION DIVISION.
PROGRAM-ID. SOLVE-CUBIC.
AUTHOR. TOM A CRONA.
INSTALLATION. LDC.
DATE-WRITTEN. OCTOBER 22,1984.
DATE-COMPILED. OCTOBER 22,1984.
SECURITY. NONE.

ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. VAX.
OBJECT-COMPUTER. VAX.
SPECIAL-NAMES.
DECIMAL-POINT IS COMMA.

DATA DIVISION.

WORKING-STORAGE SECTION.
77 ROOT-1       PICTURE S999V9(9) USAGE IS COMPUTATIONAL.
77 ROOT-2       PICTURE S999V9(9) USAGE IS COMPUTATIONAL.
77 EPS          PICTURE S999V9(9) USAGE IS COMPUTATIONAL.
77 X            PICTURE S999V9(9) USAGE IS COMPUTATIONAL.
77 OLD-X        PICTURE S999V9(9) USAGE IS COMPUTATIONAL.
77 LAST-X       PICTURE S999V9(9) USAGE IS COMPUTATIONAL.
77 NEW-X        PICTURE S999V9(9) USAGE IS COMPUTATIONAL.
77 Y            PICTURE S999V9(9) USAGE IS COMPUTATIONAL.
77 Y1           PICTURE S999V9(9) USAGE IS COMPUTATIONAL.
77 Y2           PICTURE S999V9(9) USAGE IS COMPUTATIONAL.
77 TEMP         PICTURE S999V9(9) USAGE IS COMPUTATIONAL.
77 TEMP2        PICTURE S999V9(9) USAGE IS COMPUTATIONAL.
77 EDITED-NBR   PICTURE ---9,9(9) USAGE IS DISPLAY.
77 ITERATIONS   PICTURE 99        USAGE IS COMPUTATIONAL.


PROCEDURE DIVISION.
COMPUTE-ROOTS. DISPLAY "THIS PROGRAM SOLVES 63x^3-9x^2-7x+1=0".
        COMPUTE EPS = 10 ** -5.
        PERFORM SOLVE THROUGH END-SOLVE MOVE LAST-X TO ROOT-1.

        ALTER SKIP TO PROCEED TO ELIMINATE-1.

        PERFORM SOLVE THROUGH END-SOLVE MOVE LAST-X TO ROOT-2.
        ALTER SKIP TO PROCEED TO ELIMINATE-2.
        PERFORM SOLVE THROUGH END-SOLVE.
        DISPLAY "NO MORE ROOTS".
        STOP RUN.

SOLVE.  MOVE -1 TO OLD-X MOVE ALL ZEROES TO LAST-X, ITERATIONS.
LOOP.   MOVE OLD-X TO X PERFORM COMPUTE-FUNCTION THROUGH END-FUNC
        MOVE Y TO Y1.
        MOVE LAST-X TO X PERFORM COMPUTE-FUNCTION THROUGH END-FUNC
        MOVE Y TO Y2.
        IF OLD-X - LAST-X IS LESS THAN EPS AND GREATER THAN - EPS
                 GO TO END-SOLVE.
        SUBTRACT OLD-X FROM LAST-X GIVING TEMP.
        SUBTRACT Y1 FROM Y2 GIVING TEMP2.
        MULTIPLY Y2 BY TEMP DIVIDE TEMP2 INTO TEMP.
        SUBTRACT TEMP FROM LAST-X GIVING NEW-X.
        MOVE LAST-X TO OLD-X MOVE NEW-X TO LAST-X.
        ADD 1 TO ITERATIONS.

        IF ITERATIONS IS GREATER THAN 20 DISPLAY "NO ROOT FOUND"
                                                 STOP RUN.
        IF Y2 IS LESS THAN - EPS OR GREATER THAN EPS GO TO LOOP.
END-SOLVE. MOVE LAST-X TO EDITED-NBR DISPLAY "X=", EDITED-NBR.


COMPUTE-FUNCTION. MULTIPLY 7 BY X GIVING Y
        SUBTRACT 1 FROM Y MULTIPLY X BY Y MULTIPLY 9 BY Y.
        SUBTRACT 7 FROM Y MULTIPLY X BY Y ADD 1 TO Y.
SKIP.   GO TO END-FUNC.

ELIMINATE-2. SUBTRACT ROOT-2 FROM X GIVING TEMP
        DIVIDE TEMP INTO Y.
ELIMINATE-1. SUBTRACT ROOT-1 FROM X GIVING TEMP
        DIVIDE TEMP INTO Y.
END-FUNC. EXIT.