zoukankan      html  css  js  c++  java
  • 幽默:程序员的进化[转]

    from http://coolshell.cn/?p=172

    实在是搞笑  不过那个大师级的对偶来说也忒难了 --

    2009年3月14日

    高中时期

    view plaincopy to clipboardprint?

    1. 10 PRINT "HELLO WORLD"
    2. 20 END 

    大学新生

    view plaincopy to clipboardprint?

    1. program Hello(input, output)  
    2. begin
    3. writeln(\'Hello World\')  
    4. end. 

    高年级大学生

    view plaincopy to clipboardprint?

    1. #include <stdio.h>
    2. int main(void)  
    3. {  
    4.    printf("Hello, world!\\n");  
    5. return 0;  
    6. }  
    7. </stdio.h> 

    职业新手

    view plaincopy to clipboardprint?

    1. #include <stdio.h>
    2. void main(void)  
    3. {  
    4. char *message[] = {"Hello ", "World"};  
    5. int i;  
    6. for(i = 0; i < 2; ++i)  
    7.     printf("%s", message[i]);  
    8.   printf("\\n");  
    9. }  
    10. stdio.h> 

    职业老手

    view plaincopy to clipboardprint?

    1. #include <iostream>
    2. #include <string>
    3. using namespace std;  
    4. class string  
    5. {  
    6. private:  
    7. int size;  
    8. char *ptr;  
    9. string() : size(0), ptr(new char[1]) { ptr[0] = 0; }  
    10.    string(const string &s) : size(s.size)  
    11.    {  
    12.      ptr = new char[size + 1];  
    13.      strcpy(ptr, s.ptr);  
    14.    }  
    15.    ~string()  
    16.    {  
    17. delete [] ptr;  
    18.    }  
    19. friend ostream &operator <<(ostream &, const string &);  
    20.    string &operator=(const char *);  
    21. };  
    22. ostream &operator<<(ostream &stream, const string &s)  
    23. {  
    24. return(stream << s.ptr);  
    25. }  
    26. string &string::operator=(const char *chrs)  
    27. {  
    28. if (this != &chrs)  
    29.    {  
    30. delete [] ptr;  
    31.     size = strlen(chrs);  
    32.      ptr = new char[size + 1];  
    33.      strcpy(ptr, chrs);  
    34.    }  
    35. return(*this);  
    36. }  
    37. int main()  
    38. {  
    39.    string str;  
    40.    str = "Hello World";  
    41.    cout << str << endl;  
    42. return(0);  
    43. }  
    44. /string></iostream> 

    大师级

    view plaincopy to clipboardprint?

    1.   [  
    2. uuid(2573F8F4-CFEE-101A-9A9F-00AA00342820)  
    3.   ]  
    4.   library LHello  
    5.   {  
    6. // bring in the master library
    7.       importlib("actimp.tlb");  
    8.       importlib("actexp.tlb");  
    9. // bring in my interfaces
    10.       #include "pshlo.idl"
    11.       [  
    12. uuid(2573F8F5-CFEE-101A-9A9F-00AA00342820)  
    13.       ]  
    14.       cotype THello  
    15.    {  
    16.    interface IHello;  
    17.    interface IPersistFile;  
    18.    };  
    19.   };  
    20.   [  
    21.   exe,  
    22. uuid(2573F890-CFEE-101A-9A9F-00AA00342820)  
    23.   ]  
    24.   module CHelloLib  
    25.   {  
    26. // some code related header files
    27.       importheader(<windows.h>);  
    28.       importheader(  
    29. <ole2.h>);  
    30.       importheader(<except.hxx>);  
    31.       importheader("pshlo.h");  
    32.       importheader("shlo.hxx");  
    33.       importheader("mycls.hxx");  
    34. // needed typelibs
    35.       importlib("actimp.tlb");  
    36.       importlib("actexp.tlb");  
    37.       importlib("thlo.tlb");  
    38.       [  
    39. uuid(2573F891-CFEE-101A-9A9F-00AA00342820),  
    40.       aggregatable  
    41.       ]  
    42.       coclass CHello  
    43.    {  
    44.    cotype THello;  
    45.    };  
    46.   };  
    47.   #include "ipfix.hxx"
    48. extern HANDLE hEvent;  
    49. class CHello : public CHelloBase  
    50.   {  
    51. public:  
    52.       IPFIX(CLSID_CHello);  
    53.       CHello(IUnknown *pUnk);  
    54.       ~CHello();  
    55. HRESULT  __stdcall PrintSz(LPWSTR pwszString);  
    56. private:  
    57. static int cObjRef;  
    58.   };  
    59.   #include <windows.h>
    60.   #include
    61. <ole2.h>  
    62.   #include <stdio.h>
    63.   #include <stdlib.h>
    64.   #include "thlo.h"
    65.   #include "pshlo.h"
    66.   #include "shlo.hxx"
    67.   #include "mycls.hxx"
    68. int CHello::cObjRef = 0;  
    69.   CHello::CHello(IUnknown *pUnk) : CHelloBase(pUnk)  
    70.   {  
    71.       cObjRef++;  
    72. return;  
    73.   }  
    74. HRESULT  __stdcall  CHello::PrintSz(LPWSTR pwszString)  
    75.   {  
    76.       printf("%ws
    77. ", pwszString);  
    78. return(ResultFromScode(S_OK));  
    79.   }  
    80.   CHello::~CHello(void)  
    81.   {  
    82. // when the object count goes to zero, stop the server
    83.   cObjRef--;  
    84. if( cObjRef == 0 )  
    85.       PulseEvent(hEvent);  
    86. return;  
    87.   }  
    88.   #include <windows.h>
    89.   #include
    90. <ole2.h>  
    91.   #include "pshlo.h"
    92.   #include "shlo.hxx"
    93.   #include "mycls.hxx"
    94. HANDLE hEvent;  
    95. int _cdecl main(  
    96. int argc,  
    97. char * argv[]  
    98.   ) {  
    99. ULONG ulRef;  
    100. DWORD dwRegistration;  
    101.   CHelloCF *pCF = new CHelloCF();  
    102.   hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);  
    103. // Initialize the OLE libraries
    104.   CoInitializeEx(NULL, COINIT_MULTITHREADED);  
    105.   CoRegisterClassObject(CLSID_CHello, pCF, CLSCTX_LOCAL_SERVER,  
    106.       REGCLS_MULTIPLEUSE, &dwRegistration);  
    107. // wait on an event to stop
    108.   WaitForSingleObject(hEvent, INFINITE);  
    109. // revoke and release the class object
    110.   CoRevokeClassObject(dwRegistration);  
    111.   ulRef = pCF->Release();  
    112. // Tell OLE we are going away.
    113.   CoUninitialize();  
    114. return(0); }  
    115. extern CLSID CLSID_CHello;  
    116. extern UUID LIBID_CHelloLib;  
    117.   CLSID CLSID_CHello = { /* 2573F891-CFEE-101A-9A9F-00AA00342820 */
    118.       0x2573F891,  
    119.       0xCFEE,  
    120.       0x101A,  
    121.       { 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 }  
    122.   };  
    123.   UUID LIBID_CHelloLib = { /* 2573F890-CFEE-101A-9A9F-00AA00342820 */
    124.       0x2573F890,  
    125.       0xCFEE,  
    126.       0x101A,  
    127.       { 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 }  
    128.   };  
    129.   #include <windows.h>
    130.   #include
    131. <ole2.h>  
    132.   #include <stdlib.h>
    133.   #include <string.h>
    134.   #include <stdio.h>
    135.   #include "pshlo.h"
    136.   #include "shlo.hxx"
    137.   #include "clsid.h"
    138. int _cdecl main(  
    139. int argc,  
    140. char * argv[]  
    141.   ) {  
    142. HRESULT  hRslt;  
    143.   IHello        *pHello;  
    144. ULONG  ulCnt;  
    145.   IMoniker * pmk;  
    146. WCHAR  wcsT[_MAX_PATH];  
    147. WCHAR  wcsPath[2 * _MAX_PATH];  
    148. // get object path
    149.   wcsPath[0] = \'\\0\';
    150.   wcsT[0] = \'\\0\';  
    151. if( argc > 1) {  
    152.       mbstowcs(wcsPath, argv[1], strlen(argv[1]) + 1);  
    153.       wcsupr(wcsPath);  
    154.       }  
    155. else {  
    156.       fprintf(stderr, "Object path must be specified\\n");  
    157. return(1);  
    158.       }  
    159. // get print string
    160. if(argc > 2)  
    161.       mbstowcs(wcsT, argv[2], strlen(argv[2]) + 1);  
    162. else
    163.       wcscpy(wcsT, L"Hello World");  
    164.   printf("Linking to object %ws\\n", wcsPath);  
    165.   printf("Text String %ws\\n", wcsT);  
    166. // Initialize the OLE libraries
    167.   hRslt = CoInitializeEx(NULL, COINIT_MULTITHREADED);  
    168. if(SUCCEEDED(hRslt)) {  
    169.       hRslt = CreateFileMoniker(wcsPath, &pmk);  
    170. if(SUCCEEDED(hRslt))  
    171.    hRslt = BindMoniker(pmk, 0, IID_IHello, (void **)&pHello);  
    172. if(SUCCEEDED(hRslt)) {  
    173. // print a string out
    174.    pHello->PrintSz(wcsT);  
    175.    Sleep(2000);  
    176.    ulCnt = pHello->Release();  
    177.    }  
    178. else
    179.    printf("Failure to connect, status: %lx", hRslt);  
    180. // Tell OLE we are going away.
    181.       CoUninitialize();  
    182.       }  
    183. return(0);  
    184.   }  
    185. </stdio.h></string.h></stdlib.h></ole2.h></windows.h></ole2.h></windows.h></stdlib.h></stdio.h></ole2.h></windows.h></except.hxx></ole2.h></windows.h> 

    黑客学徒

      #!/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;
    

    有经验的黑客

    view plaincopy to clipboardprint?

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

    老练的黑客

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

    超级黑客

      % echo "Hello, world."
    

    一线经理

    view plaincopy to clipboardprint?

    1. 10 PRINT "HELLO WORLD"
    2. 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.
      ^D
    

    高级经理

      % zmail jim
      I need a "Hello, world." program by this afternoon.
    

    首席执行官

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

    来源:未知

    关于更多的“hello world”请参看:《Hello World 集中营

  • 相关阅读:
    最短路径问题/Spfa
    cddiv/数组维护
    cfdiv2/c/找规律
    Codeforces Round #343 (Div. 2)【A,B水题】
    POJ 2135_Farm Tour
    POJ 3469_Dual Core CPU
    POJ 3469_Dual Core CPU
    POJ 3281_Dining
    POJ 3281_Dining
    POJ 3041_Asteroids
  • 原文地址:https://www.cnblogs.com/elanp/p/1663653.html
Copyright © 2011-2022 走看看