Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Guess what the program does!


Admiral Refuge
 Share

Recommended Posts

**For those who have guessed correctly, here:**
http://www.touchofdeathforums.com/smf/index.php?topic=42526.msg425142#msg425142

Everyone who was in the Eclipse Chat room while we were talking about these languages(you know who you are), DO NOT POST; I want to see who can identify these (if you're an old-schooler, just PM me with what you think they are).

Who can tell me what programming languages these are:
**1: C++ (Fruitpunch found the answer)**
```
#include using namespace std;

int main()
{
  int a[]={5,4,2,8,1,9,2,10,3,7,6};
  int i,j,temp;
  for(i=0;i<11;i++)
      cout<a[j+1])
        {
            temp=a[j];
            a[j]=a[j+1];
            a[j+1]=temp;
        }

  for(i=0;i<11;i++)
      cout<;

foreach(sort mysort @words) {
print;
}

sub mysort {
$aa=$a;$bb=$b;
($aa =~ tr/eE/eE/) <=> ($bb=~ tr/eE/eE/) || lc($a) cmp lc($b);
}[/code]
[b]3: [color]Plankalkül (Zananok found the answer, and without google!)[/color][/b]
[code]W1[0](4)
[
  V0[i0:8.0] => Z0[i0:8.0]
  1 => Z4[:32.0]
  W1[1](i0)
  [
      (V0[i0:8.0] < Z0[i1:8.0]) & (Z4[:32.0]=1) ->
      [
        i0-i1 => Z1[:32.0]
        W1[2](Z1[:32.0])
        [
            i0 - i2 - 1 => Z3[:32.0]
            i0 - i2 => Z2[:32.0]
            Z0[Z3[:32.0]:8.0] => Z0[Z2[:32.0]:8.0]
        ]
        V0[i0:8.0] => Z0[i1:8.0]
        0 => Z4[:32.0]
        ]
  ]
]
END[/code]
[b]4: [color]FORTRAN (Fruitpunch found the answer)[/color][/b]
[code]  SUBROUTINE SSORT (X, IY, N, KFLAG)
      IMPLICIT NONE
      INTEGER KFLAG, N
      REAL X(1:N)
      INTEGER IY(N)
      REAL TEMP
      INTEGER I, ISWAP(1), ITEMP, ISWAP1
      INTRINSIC MAXLOC
      DO 200 I=1,N-1
        ISWAP=MAXLOC(X(I:N))
        ISWAP1=ISWAP(1)+I-1
        IF(ISWAP1.NE.I) THEN
          TEMP=X(I)
            X(I)=X(ISWAP1)
            X(ISWAP1)=TEMP
            ITEMP=IY(I)
            IY(I)=IY(ISWAP1)
            IY(ISWAP1)=ITEMP
        ENDIF
  200 CONTINUE
      RETURN
      END[/code]
[b]5: [color]Forth (Skell found the answer; did he google?)[/color][/b]
[code]
:
sort depth 2 > if over over < if swap then rot over over < if swap then -> a recurse a else over over < if swap then then
;
[/code]
[b]6: [color]COBOL (Tyr found the answer)[/color][/b]
[code]      $ SET SOURCEFORMAT"FREE"
IDENTIFICATION DIVISION.
PROGRAM-ID.  InputSort.
AUTHOR.  Michael Coughlan.

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
    SELECT StudentFile ASSIGN TO "SORTSTUD.DAT"
ORGANIZATION IS LINE SEQUENTIAL.
    SELECT WorkFile ASSIGN TO "WORK.TMP".

DATA DIVISION.
FILE SECTION.
FD StudentFile.
01 StudentDetails      PIC X(30).

SD WorkFile.
01 WorkRec.
  02 WStudentId      PIC 9(7).
  02 FILLER          PIC X(23).

PROCEDURE DIVISION.
Begin.
  SORT WorkFile ON ASCENDING KEY WStudentId
        INPUT PROCEDURE IS GetStudentDetails
        GIVING StudentFile.
  STOP RUN.

GetStudentDetails.
    DISPLAY "Enter student details using template below."
    DISPLAY "Enter no data to end.".
    DISPLAY "Enter - StudId, Surname, Initials, YOB, MOB, DOB, Course, Gender"
    DISPLAY "NNNNNNNSSSSSSSSIIYYYYMMDDCCCCG"
    ACCEPT  WorkRec.
    PERFORM UNTIL WorkRec = SPACES
      RELEASE WorkRec
      ACCEPT WorkRec
    END-PERFORM.
[/code]
[b]7: [color]Assembly (StingRay found the answer)[/color][/b]
[code]          add  $s3, $zero, $zero
fors:  slt  $t2, $s3, $s2
          beq  $t2, $zero, endfors
          add  $t0, $s3, $zero
          sll  $t3, $s3, 2
          add  $a0, $s0, $t3
          sll  $t3, $t0, 2
          add  $a1, $s0, $t3 
          jal  Swap
          addi $s3, $s3, 1    # s++
          j    fors
endfors:
addi $sp, $sp, -20 
sw  $ra, 16($sp)  lw  $ra, 16($sp)
sw  $s3, 12($sp)  lw  $s3, 12($sp)
sw  $s2,  8($sp)  lw  $s2,  8($sp)
sw  $s1,  4($sp)  lw  $s1,  4($sp)
sw  $s0,  0($sp)  lw  $s0,  0($sp)
                                  addi $sp, $sp, 20

add  $s0, $a0, $zero
add  $s1, $a1, $zero  jr  $ra

addi $s2, $s1, -1
[/code]
The person who guesses the languages correctly, can put up examples of other ones for other ppl to guess :azn:

NOTE: The logic may be off on some of these, but you just need the syntax to tell what language it is anyway

EDIT: I have a feeling Godlord is going to come into this topic, and not only identify all of these, but then explain what's wrong in the syntax[/i][/i]

```
Link to comment
Share on other sites

@Fruitpunch:

> im guessing one of those is fortran but thats the only ancient computer language I have heard of

Not all of them here are acient; I'll modify one of the languages, it will make more sense (I forgot the header)

EDIT: Also yes, one of them are FORTRAN; just got to guess which one XD
Link to comment
Share on other sites

@Zananok:

> I needed google for the 5th… Sadly, but I did heard the name before though... Just haven't seen it in action before.
>
> Comments,
> From: Zananok

I see; either way, you got afew of them right (and getting Plankalkul right WITHOUT googling it, that's amazing!)
EDIT: Only reason I didn't put the 5th one up yet, is because you googled it (and I want to see who else can take a swing at it; though I'm sure someone is bound to google it now anyways)
Link to comment
Share on other sites

@ÅÐмiядζ:

> I see; either way, you got afew of them right (and getting Plankalkul right WITHOUT googling it, that's amazing!)
> EDIT: Only reason I didn't put the 5th one up yet, is because you googled it (and I want to see who else can take a swing at it; though I'm sure someone is bound to google it now anyways)

Don't worry, I dont mind ;)
But like you said, hopefully someone can without google.

Comments,
From: Zananok
Link to comment
Share on other sites

@ÅÐмiядζ:

> You would guess right, which means either:
>
> * You googled
> * You were one of the hardcore programmers that tried to learn forth, but it pushed you over the edge
> * You managed to actually learn Forth

None, I am one that know one who 

* were one of the hardcore programmers that tried to learn forth, but it pushed you over the edge
Link to comment
Share on other sites

Okay, now what?  Now you tell me what each program does, if you're soooo smart XD

Don't just tell me what it does, but HOW it does it XD

C++ (this is for Fruitpunch; if ya can't figure it out, someone else is welcomed to, but you need to tell us you can't figure it out!)
```
#include using namespace std;
const char K = ' ';
int main()
{
char M8[4] = " TH";
char M = 'L', D = 'R', Y[3] = "ME", H[4] = "OST", R[3] = "JU", A[3] = "ST";
cout << 'U' << K;
cout << R << A;
cout << K << M << H << M8 << "E ";
cout << 'G' << 'A' << Y;
cout << endl;
return 0;
}

```
Perl (Aksel, you BETTER be able to figure this one)
**Aksel Figured this one out (email system)**
```
#!/usr/bin/perl -w use strict;
use CGI;
use Email::Valid;
my $query = new CGI;
unless (Email::Valid->address($query->param('send_to'))) {
  print $query->header;
  print "You supplied an invalid email address.";
  exit;
}
my $sendmail = "/usr/sbin/sendmail -t";
my $reply_to = "Reply-to: foo\@bar.org\n";
my $subject = "Subject: Confirmation of your submission\n";
my $content = "Thanks for your submission.";
my $to = $query->param('send_to')."\n";
my $file = "subscribers.txt"; unless ($to) {
print $query->header; print "Please fill in your email and try again";
} open (FILE, ">>$file") or die "Cannot open $file: $!";
print $to,"\n";
close(FILE); my $send_to = "To: ".$query->param('send_to');
open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail: $!";
print SENDMAIL $reply_to; print SENDMAIL $subject;
print SENDMAIL $send_to;
print SENDMAIL "Content-type: text/plain\n\n";
print SENDMAIL $content; close(SENDMAIL);
print $query->header;
print "Confirmation of your submission will be emailed to you.";
```
Plankalkül - this is open to anyone who can figure it out without google (explain to me HOW it works, not what it does)
```
P5 R(V0[:32.0]) => R0[:32.0]

1 => Z0[:32.0]

W1 (5)
[

  i * Z0[:32.0] => Z0[:32.0]

]

Z0[:32.0] => R0[:32.0]

END
```
FORTRAN - Pretty streightforward (my syntax may be off, but you can still see what it's doing)
```
      PROGRAM MAIN
      COMMON /GLOBALS/ M
      INTEGER N
      EXTERNAL SUB1
      PRINT *, 'Enter value'
      READ (*,*) N
      CALL SUB1(N)
      END

      SUBROUTINE SUB1(N)
      M=N*N
      PRINT *, M
      RETURN
      END

```
Forth (You want a try at it Skell?  Who wants one?)
```
hex 4666 dup negate do i 4000 dup 2* negate do " *" 0 dup 2dup 1e 0 do
2swap * e >>a 2* 5 pick + -rot - j + dup dup * e >>a rot dup dup * e >>a
rot swap 2dup + 10000 > if 3drop 3drop "  " 0 dup 2dup leave then loop
2drop 2drop type 268 +loop cr drop 5de +loop ;
```Na, I'm kidding… The above though, would generate the MandelbrotSet, but I couldn't get it to work.. So, someone figure this out:
```
: fac  1 swap  1 max  1+ 2 ?do i * loop ;

```And then, someone puts in the Forth Terminal:
5 fac

I'll leave COBOL and ASM out ;)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...