免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
123下一页
最近访问板块 发新帖
查看: 23205 | 回复: 22
打印 上一主题 下一主题

程序员的进化——从学生到首席执行官 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-02-10 13:22 |只看该作者 |倒序浏览
    


  1. /*-------------------------------------------

  2.     程序员的进化——从学生到首席执行官

  3. 翻译 2002 王咏刚 http://www.contextfree.net/
  4. 转译自 Omri's Computer Humor Page
  5. http://www.cs.bgu.ac.il/~omri/Humor/
  6. -------------------------------------------*/


  7. --------------------------------------------------------------------------------
  8. 中学阶段

  9.           10 PRINT "HELLO WORLD"
  10.           20 END
  11. --------------------------------------------------------------------------------
  12. 大学一年级

  13.           program Hello(input, output)
  14.             begin
  15.               writeln('Hello World')
  16.             end.
  17. --------------------------------------------------------------------------------
  18. 大学高年级

  19.           (defun hello
  20.             (print
  21.               (cons 'Hello (list 'World))))
  22. --------------------------------------------------------------------------------
  23. 初级程序员

  24.           #include <stdio.h>;
  25.           void main(void)
  26.           {
  27.             char *message[] = {"Hello ", "World"};
  28.             int i;

  29.             for(i = 0; i < 2; ++i)
  30.               printf("%s", message[i]);
  31.             printf("\n");
  32.           }
  33. --------------------------------------------------------------------------------
  34. 编程老鸟

  35.           #include <iostream.h>;
  36.           #include <string.h>;

  37.           class string
  38.           {
  39.           private:
  40.             int size;
  41.             char *ptr;

  42.           public:
  43.             string() : size(0), ptr(new char('\0')) {}

  44.             string(const string &s) : size(s.size)
  45.             {
  46.               ptr = new char[size + 1];
  47.               strcpy(ptr, s.ptr);
  48.             }

  49.             ~string()
  50.             {
  51.               delete [] ptr;
  52.             }

  53.             friend ostream &operator <<(ostream &, const string &);
  54.             string &operator=(const char *);
  55.           };

  56.           ostream &operator<<(ostream &stream, const string &s)
  57.           {
  58.             return(stream << s.ptr);
  59.           }

  60.           string &string::operator=(const char *chrs)
  61.           {
  62.             if (this != &chrs)
  63.             {
  64.               delete [] ptr;
  65.              size = strlen(chrs);
  66.               ptr = new char[size + 1];
  67.               strcpy(ptr, chrs);
  68.             }
  69.             return(*this);
  70.           }

  71.           int main()
  72.           {
  73.             string str;

  74.             str = "Hello World";
  75.             cout << str << end

  76.             return(0);
  77.           }
  78. --------------------------------------------------------------------------------
  79. 编程高手

  80.           [
  81.           uuid(2573F8F4-CFEE-101A-9A9F-00AA00342820)
  82.           ]
  83.           library LHello
  84.           {
  85.               // bring in the master library
  86.               importlib("actimp.tlb");
  87.               importlib("actexp.tlb");

  88.               // bring in my interfaces
  89.               #include "pshlo.idl"

  90.               [
  91.               uuid(2573F8F5-CFEE-101A-9A9F-00AA00342820)
  92.               ]
  93.               cotype THello
  94.            {
  95.            interface IHello;
  96.            interface IPersistFile;
  97.            };
  98.           };

  99.           [
  100.           exe,
  101.           uuid(2573F890-CFEE-101A-9A9F-00AA00342820)
  102.           ]
  103.           module CHelloLib
  104.           {

  105.               // some code related header files
  106.               importheader(<windows.h>;);
  107.               importheader(<ole2.h>;);
  108.               importheader(<except.hxx>;);
  109.               importheader("pshlo.h");
  110.               importheader("shlo.hxx");
  111.               importheader("mycls.hxx");

  112.               // needed typelibs
  113.               importlib("actimp.tlb");
  114.               importlib("actexp.tlb");
  115.               importlib("thlo.tlb");

  116.               [
  117.               uuid(2573F891-CFEE-101A-9A9F-00AA00342820),
  118.               aggregatable
  119.               ]
  120.               coclass CHello
  121.            {
  122.            cotype THello;
  123.            };
  124.           };

  125.           #include "ipfix.hxx"

  126.           extern HANDLE hEvent;

  127.           class CHello : public CHelloBase
  128.           {
  129.           public:
  130.               IPFIX(CLSID_CHello);

  131.               CHello(IUnknown *pUnk);
  132.               ~CHello();

  133.               HRESULT  __stdcall PrintSz(LPWSTR pwszString);

  134.           private:
  135.               static int cObjRef;
  136.           };

  137.           #include <windows.h>;
  138.           #include <ole2.h>;
  139.           #include <stdio.h>;
  140.           #include <stdlib.h>;
  141.           #include "thlo.h"
  142.           #include "pshlo.h"
  143.           #include "shlo.hxx"
  144.           #include "mycls.hxx"

  145.           int CHello::cObjRef = 0;

  146.           CHello::CHello(IUnknown *pUnk) : CHelloBase(pUnk)
  147.           {
  148.               cObjRef++;
  149.               return;
  150.           }

  151.           HRESULT  __stdcall  CHello::PrintSz(LPWSTR pwszString)
  152.           {
  153.               printf("%ws\n", pwszString);
  154.               return(ResultFromScode(S_OK));
  155.           }

  156.           CHello::~CHello(void)
  157.           {

  158.           // when the object count goes to zero, stop the server
  159.           cObjRef--;
  160.           if( cObjRef == 0 )
  161.               PulseEvent(hEvent);

  162.           return;
  163.           }

  164.           #include <windows.h>;
  165.           #include <ole2.h>;
  166.           #include "pshlo.h"
  167.           #include "shlo.hxx"
  168.           #include "mycls.hxx"

  169.           HANDLE hEvent;

  170.            int _cdecl main(
  171.           int argc,
  172.           char * argv[]
  173.           ) {
  174.           ULONG ulRef;
  175.           DWORD dwRegistration;
  176.           CHelloCF *pCF = new CHelloCF();

  177.           hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);

  178.           // Initialize the OLE libraries
  179.           CoInitializeEx(NULL, COINIT_MULTITHREADED);

  180.           CoRegisterClassObject(CLSID_CHello, pCF, CLSCTX_LOCAL_SERVER,
  181.               REGCLS_MULTIPLEUSE, &dwRegistration);

  182.           // wait on an event to stop
  183.           WaitForSingleObject(hEvent, INFINITE);

  184.           // revoke and release the class object
  185.           CoRevokeClassObject(dwRegistration);
  186.           ulRef = pCF->;Release();

  187.           // Tell OLE we are going away.
  188.           CoUninitialize();

  189.           return(0);
  190.           }

  191.           extern CLSID CLSID_CHello;
  192.           extern UUID LIBID_CHelloLib;

  193.           CLSID CLSID_CHello = { /* 2573F891-CFEE-101A-9A9F-00AA00342820 */
  194.               0x2573F891,
  195.               0xCFEE,
  196.               0x101A,
  197.               { 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 }
  198.           };

  199.           UUID LIBID_CHelloLib = { /* 2573F890-CFEE-101A-9A9F-00AA00342820 */
  200.               0x2573F890,
  201.               0xCFEE,
  202.               0x101A,
  203.               { 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 }
  204.           };

  205.           #include <windows.h>;
  206.           #include <ole2.h>;
  207.           #include <stdlib.h>;
  208.           #include <string.h>;
  209.           #include <stdio.h>;
  210.           #include "pshlo.h"
  211.           #include "shlo.hxx"
  212.           #include "clsid.h"

  213.           int _cdecl main(
  214.           int argc,
  215.           char * argv[]
  216.           ) {
  217.           HRESULT  hRslt;
  218.           IHello        *pHello;
  219.           ULONG  ulCnt;
  220.           IMoniker * pmk;
  221.           WCHAR  wcsT[_MAX_PATH];
  222.           WCHAR  wcsPath[2 * _MAX_PATH];

  223.           // get object path
  224.           wcsPath[0] = '\0';
  225.           wcsT[0] = '\0';
  226.           if( argc >; 1) {
  227.               mbstowcs(wcsPath, argv[1], strlen(argv[1]) + 1);
  228.               wcsupr(wcsPath);
  229.               }
  230.           else {
  231.               fprintf(stderr, "Object path must be specified\n");
  232.               return(1);
  233.               }

  234.           // get print string
  235.           if(argc >; 2)
  236.               mbstowcs(wcsT, argv[2], strlen(argv[2]) + 1);
  237.           else
  238.               wcscpy(wcsT, L"Hello World");

  239.           printf("Linking to object %ws\n", wcsPath);
  240.           printf("Text String %ws\n", wcsT);

  241.           // Initialize the OLE libraries
  242.           hRslt = CoInitializeEx(NULL, COINIT_MULTITHREADED);

  243.           if(SUCCEEDED(hRslt)) {

  244.               hRslt = CreateFileMoniker(wcsPath, &pmk);
  245.               if(SUCCEEDED(hRslt))
  246.            hRslt = BindMoniker(pmk, 0, IID_IHello, (void **)&pHello);

  247.               if(SUCCEEDED(hRslt)) {

  248.            // print a string out
  249.            pHello->;PrintSz(wcsT);

  250.            Sleep(2000);
  251.            ulCnt = pHello->;Release();
  252.            }
  253.               else
  254.            printf("Failure to connect, status: %lx", hRslt);

  255.               // Tell OLE we are going away.
  256.               CoUninitialize();
  257.               }

  258.           return(0);
  259.           }
  260. --------------------------------------------------------------------------------
  261. 黑客初阶

  262.           #!/usr/local/bin/perl
  263.           $msg="Hello, world.\n";
  264.           if ($#ARGV >;= 0) {
  265.             while(defined($arg=shift(@ARGV))) {
  266.               $outfilename = $arg;
  267.               open(FILE, ">;" . $outfilename) || die "Can't write $arg: $!\n";
  268.               print (FILE $msg);
  269.               close(FILE) || die "Can't close $arg: $!\n";
  270.             }
  271.           } else {
  272.             print ($msg);
  273.           }
  274.           1;
  275. --------------------------------------------------------------------------------
  276. 黑客有成

  277.           #include <stdio.h>;
  278.           #define S "Hello, World\n"
  279.           main(){exit(printf(S) == strlen(S) ? 0 : 1);}
  280. --------------------------------------------------------------------------------
  281. 黑客高手

  282.           % cc -o a.out ~/src/misc/hw/hw.c
  283.           % a.out
  284. --------------------------------------------------------------------------------
  285. 黑客大虾

  286.           % cat
  287.           Hello, world.
  288.           ^D
  289. --------------------------------------------------------------------------------
  290. 初级经理

  291.           10 PRINT "HELLO WORLD"
  292.           20 END
  293. --------------------------------------------------------------------------------
  294. 中级经理

  295.           mail -s "Hello, world." bob@b12
  296.           Bob, could you please write me a program that prints "Hello, world."?
  297.           I need it by tomorrow.
  298.           ^D
  299. --------------------------------------------------------------------------------
  300. 高级经理

  301.           % zmail jim
  302.           I need a "Hello, world." program by this afternoon.
  303. --------------------------------------------------------------------------------
  304. 首席执行官

  305.           % letter
  306.           letter: Command not found.
  307.           % mail
  308.           To: ^X ^F ^C
  309.           % help mail
  310.           help: Command not found.
  311.           % damn!
  312.           !: Event unrecognized
  313.           % logout
  314. --------------------------------------------------------------------------------

复制代码

论坛徽章:
0
2 [报告]
发表于 2004-02-11 13:06 |只看该作者

程序员的进化——从学生到首席执行官

有趣!

论坛徽章:
0
3 [报告]
发表于 2004-11-22 21:29 |只看该作者

程序员的进化——从学生到首席执行官

It's the most biggest fun at the world!

论坛徽章:
0
4 [报告]
发表于 2004-11-23 15:29 |只看该作者

程序员的进化——从学生到首席执行官

so funny~

论坛徽章:
0
5 [报告]
发表于 2004-11-24 14:31 |只看该作者

程序员的进化——从学生到首席执行官

首席执行官

          % letter
          letter: Command not found.
          % mail
          To: ^X ^F ^C
          % help mail
          help: Command not found.
          % damn!
          !: Event unrecognized
          % logout
--------------------------------------------------------------------------------
笑的肚子疼。

论坛徽章:
0
6 [报告]
发表于 2004-11-26 13:53 |只看该作者

程序员的进化——从学生到首席执行官

哎,可悲的世界 ……

论坛徽章:
0
7 [报告]
发表于 2005-02-02 14:51 |只看该作者

程序员的进化——从学生到首席执行官

哈哈

论坛徽章:
0
8 [报告]
发表于 2005-02-03 09:59 |只看该作者

程序员的进化——从学生到首席执行官

有趣,不过只是分工不同。

论坛徽章:
0
9 [报告]
发表于 2005-02-03 10:06 |只看该作者

程序员的进化——从学生到首席执行官

^_^

论坛徽章:
0
10 [报告]
发表于 2008-08-26 22:27 |只看该作者
funny
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP