GNU 主页 / GNU 幽默 / 软件 /

这是针对英文原版页面的中文翻译。

你好世界!

作者:Dennis Lou 等

人们编写“你好世界”的代码根据年龄和职业而不同:

初中生/高中生

 10 PRINT "你好世界"
 20 END

大学新生

 program Hello(input, output)
 begin
 writeln('你好世界')
 end.

高年级大学生

 (defun hello
 (print
 (cons '你好 (list '世界))))

新员工

 #include <stdio.h>
 void main(void)
 {
 char *message[] = {"你好", "世界"};
 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 = "你好世界";
 cout << str << endl;
 return(0);
 }

系统管理员

 #include <stdio.h>
 #include <stdlib.h>
 main()
 {
 char *tmp;
 int i=0;
 /* on y va bourin */
 tmp=(char *)malloc(1024*sizeof(char));
 while (tmp[i]="你好世界"[i++]);
 /* Ooopps y'a une infusion ! */
 i=(int)tmp[8];
 tmp[8]=tmp[9];
 tmp[9]=(char)i;
 printf("%s\n",tmp);
 }

黑客学徒

 #!/usr/local/bin/perl
 $msg="你好世界\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 "你好世界\n"
 main(){exit(printf(S) == strlen(S) ? 0 : 1);}

黑客老手

 % cc -o a.out ~/src/misc/hw/hw.c
 % a.out
 你好世界

黑客高手

 % cat
 你好世界

新经理(还记得吗?)

 10 PRINT "你好世界"
 20 END

中级经理

 mail -s "你好世界" bob@b12
 Bob,你可以帮我写一个打印"你好世界"的程序吗?
 我明天就要。
 ^D

高级经理

 % zmail jim
 我下午需要一个"你好世界"程序。

首席执行

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

研究科学家

 PROGRAM HELLO
 PRINT *, '你好世界'
 END

资深研究科学家

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

本页的笑话取自 FSF 的 GNU 工程电子邮件档案。在 rec.humor.funny(1990年)也有一些类似的笑话。