AI Fantasy
Don't ever underestimate a heart of the champion!
经典问题 --打印"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
               void main(void)
               {
                 char *message[] = {"Hello ", "World"};
                 int i;
                 for(i = 0; i < 2; ++i)
                   printf("%s", message[i]);
                 printf("\n");
               }
            职业老手:
            ===================
               #include
               #include
               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
               #define S "Hello, World\n"
               main(){exit(printf(S) == strlen(S) ? 0 : 1);}
            骇客高手:
            =======================
               % cc -o a.out ~/src/misc/hw/hw.c
               % a.out
            骇客祖师:
            ===================
               % cat
               Hello, world.
               ^D
            新任经理:
            ===================
               10 PRINT "HELLO WORLD"
               20 END
           中级经理:
           ===================
               mail -s "Hello, world." bob@b12
               Bob, could you please write me a program that prints "Hello,
            world."?
               I need it by tomorrow.
                          ( Bob,请帮我写一个打印 "Hello World" 的程式,好吗

明天要。)
               ^D
            高级经理:
            ===================
               % zmail jim
               I need a "Hello, world." program by this afternoon.
             ( 我今天下午需要一个打印 "Hello World" 的程式。)
            首席执行官:
            ===================
               % letter
               letter: Command not found.
               % mail
               To: ^X ^F ^C
               % help mail
               help: Command not found.
               % damn!
               !: Event unrecognized
               % logout

posted on 2007-05-15 23:09 AIFantasy 阅读(186) 评论(0)  编辑 收藏 引用 所属分类: 编程珠玑
只有注册用户登录后才能发表评论。