Hello World !

кто и как кодит "Hello World", зависит от опыта кодера и места :-)



В школе

 10 PRINT "HELLO WORLD"
 20 END
 


Первый год универа

 program Hello(input, output)
 begin
 writeln('Hello World')
 end.
 

Выпускной год универа

 (defun hello
 (print
 (cons 'Hello (list 'World))))
 


Начинающий программист

 #include <stdio.h>
 
 void main(void)
 {
  char *message[] = {"Hello ", "World"};
  int i;
  for(i = 0; i < 2; ++i)
  printf("%s", message[i]);
  printf("\n");
 }
 

Опытный программист

 #include <iostream.h>
 #include <string.h>

 class string
 {
  private:
   int size;
   char *ptr;
  public:
   string() : size(0), ptr(new char('\0')) {}
   string(const string &s) : size(s.size)
   {
     ptr = new char[size + 1];
     strcpy(ptr, s.ptr);
   }
   ~string()
   {
     delete [] ptr;
   }
   friend ostream &operator <<(ostream &, const string &);
   string &operator=(const char *);
 };
								     
 ostream &operator<<(ostream &stream, const string &s)
 {
   return(stream << s.ptr);
 }
 string &string::operator=(const char *chrs)
 {
   if (this != &chrs)
   {
     delete [] ptr;
     size = strlen(chrs);
     ptr = new char[size + 1];
     strcpy(ptr, chrs);
   }
   return(*this);
 }
 int main()
 {
   string str;
   str = "Hello World";
   cout << str << endl;
   return(0);
 }
 

Сисадмин

 #include <stdio.h>
 #include <stdlib.h>
 main()
 {
  char *tmp;
  int i=0;
  /* начинаем.. */
  tmp=(char *)malloc(1024*sizeof(char));
  while (tmp[i]="Hello Wolrd"[i++]);
  /* Упс, а это что ! */
  i=(int)tmp[8];
  tmp[8]=tmp[9];
  tmp[9]=(char)i;
  printf("%s\n",tmp);
 }



Начинающий хакер

 #!/usr/local/bin/perl
 $msg="Hello, world.\n";
 if ($#ARGV >= 0) {
     while(defined($arg=shift(@ARGV))) {
         $outfilename = $arg;
         open(FILE, ">" . $outfilename) || die "Can't write $arg: $!\n";
         print (FILE $msg);
         close(FILE) || die "Can't close $arg: $!\n";
     }
 } else {
     print ($msg);
 }
 1;

Хакер со стажем

 #include <stdio.h>
 #include <string.h>
 #define S "Hello, World\n"
 main(){exit(printf(S) == strlen(S) ? 0 : 1);}
 

Опытный хакер

 % cc -o a.out ~/src/misc/hw/hw.c
 % a.out
 Hello, world.
 

Гуру в хакинге

 % cat
 Hello, world.



Начинающий менеджер

 10 PRINT "HELLO WORLD"
 20 END
 

Менеджер среднего звена

 mail -s "Hello, world." vasya@v12
 Вася, не можешь такую программу написать, которая печатает "Hello, world."?
 Мне она нужна завтра.
 ^D
 

Старший менеджер

 % zmail Петя
 Мне нужна программа "Hello, world." после обеда.


Директор

 % letter
 letter: Command not found.
 % mail
 To: ^X ^F ^C
 % help mail
 help: Command not found.
 % damn!
 !: Event unrecognized
 % logout



Младшик научный сотрудник

        PROGRAM HELLO
	PRINT *, 'Hello World'
	END

Старший научный сотрудник

	WRITE (6, 100)
    100 FORMAT (1H ,11HHELLO WORLD)
	CALL EXIT
	END

back content next