电脑疯子技术论坛|电脑极客社区

微信扫一扫 分享朋友圈

已有 1908 人浏览分享

程序员的进化[转载]

[复制链接]
1908 1

  1. --------------------------------------------------------------------------------
  2. 中学阶段

  3.           10 PRINT "HELLO WORLD"
  4.           20 END
  5. --------------------------------------------------------------------------------
  6. 大学一年级

  7.           program Hello(input, output)
  8.             begin
  9.               writeln($1$Hello World$1$)
  10.             end.
  11. --------------------------------------------------------------------------------
  12. 大学高年级

  13.           (defun hello
  14.             (print
  15.               (cons $1$Hello (list $1$World))))
  16. --------------------------------------------------------------------------------
  17. 初级程序员

  18.           #include <stdio.h>
  19.           void main(void)
  20.           {
  21.             char *message[] = {"Hello ", "World"};
  22.             int i;

  23.             for(i = 0; i < 2; ++i)
  24.               printf("%s", message[i]);
  25.             printf("\n");
  26.           }
  27. --------------------------------------------------------------------------------
  28. 编程老鸟

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

  31.           class string
  32.           {
  33.           private:
  34.             int size;
  35.             char *ptr;

  36.           public:
  37.             string() : size(0), ptr(new char($1$\0$1$)) {}

  38.             string(const string &s) : size(s.size)
  39.             {
  40.               ptr = new char[size + 1];
  41.               strcpy(ptr, s.ptr);
  42.             }

  43.             ~string()
  44.             {
  45.               delete [] ptr;
  46.             }

  47.             friend ostream &operator <<(ostream &, const string &);
  48.             string &operator=(const char *);
  49.           };

  50.           ostream &operator<<(ostream &stream, const string &s)
  51.           {
  52.             return(stream << s.ptr);
  53.           }

  54.           string &string::operator=(const char *chrs)
  55.           {
  56.             if (this != &chrs)
  57.             {
  58.               delete [] ptr;
  59.              size = strlen(chrs);
  60.               ptr = new char[size + 1];
  61.               strcpy(ptr, chrs);
  62.             }
  63.             return(*this);
  64.           }

  65.           int main()
  66.           {
  67.             string str;

  68.             str = "Hello World";
  69.             cout << str << end

  70.             return(0);
  71.           }
  72. --------------------------------------------------------------------------------
  73. 编程高手

  74.           [
  75.           uuid(2573F8F4-CFEE-101A-9A9F-00AA00342820)
  76.           ]
  77.           library LHello
  78.           {
  79.               // bring in the master library
  80.               importlib("actimp.tlb");
  81.               importlib("actexp.tlb");

  82.               // bring in my interfaces
  83.               #include "pshlo.idl"

  84.               [
  85.               uuid(2573F8F5-CFEE-101A-9A9F-00AA00342820)
  86.               ]
  87.               cotype THello
  88.            {
  89.            interface IHello;
  90.            interface IPersistFile;
  91.            };
  92.           };

  93.           [
  94.           exe,
  95.           uuid(2573F890-CFEE-101A-9A9F-00AA00342820)
  96.           ]
  97.           module CHelloLib
  98.           {

  99.               // some code related header files
  100.               importheader(<windows.h>);
  101.               importheader(<ole2.h>);
  102.               importheader(<except.hxx>);
  103.               importheader("pshlo.h");
  104.               importheader("shlo.hxx");
  105.               importheader("mycls.hxx");

  106.               // needed typelibs
  107.               importlib("actimp.tlb");
  108.               importlib("actexp.tlb");
  109.               importlib("thlo.tlb");

  110.               [
  111.               uuid(2573F891-CFEE-101A-9A9F-00AA00342820),
  112.               aggregatable
  113.               ]
  114.               coclass CHello
  115.            {
  116.            cotype THello;
  117.            };
  118.           };

  119.           #include "ipfix.hxx"

  120.           extern HANDLE hEvent;

  121.           class CHello : public CHelloBase
  122.           {
  123.           public:
  124.               IPFIX(CLSID_CHello);

  125.               CHello(IUnknown *pUnk);
  126.               ~CHello();

  127.               HRESULT  __stdcall PrintSz(LPWSTR pwszString);

  128.           private:
  129.               static int cObjRef;
  130.           };

  131.           #include <windows.h>
  132.           #include <ole2.h>
  133.           #include <stdio.h>
  134.           #include <stdlib.h>
  135.           #include "thlo.h"
  136.           #include "pshlo.h"
  137.           #include "shlo.hxx"
  138.           #include "mycls.hxx"

  139.           int CHello::cObjRef = 0;

  140.           CHello::CHello(IUnknown *pUnk) : CHelloBase(pUnk)
  141.           {
  142.               cObjRef++;
  143.               return;
  144.           }

  145.           HRESULT  __stdcall  CHello::PrintSz(LPWSTR pwszString)
  146.           {
  147.               printf("%ws\n", pwszString);
  148.               return(ResultFromScode(S_OK));
  149.           }

  150.           CHello::~CHello(void)
  151.           {

  152.           // when the object count goes to zero, stop the server
  153.           cObjRef--;
  154.           if( cObjRef == 0 )
  155.               PulseEvent(hEvent);

  156.           return;
  157.           }

  158.           #include <windows.h>
  159.           #include <ole2.h>
  160.           #include "pshlo.h"
  161.           #include "shlo.hxx"
  162.           #include "mycls.hxx"

  163.           HANDLE hEvent;

  164.            int _cdecl main(
  165.           int argc,
  166.           char * argv[]
  167.           ) {
  168.           ULONG ulRef;
  169.           DWORD dwRegistration;
  170.           CHelloCF *pCF = new CHelloCF();

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

  172.           // Initialize the OLE libraries
  173.           CoInitializeEx(NULL, COINIT_MULTITHREADED);

  174.           CoRegisterClassObject(CLSID_CHello, pCF, CLSCTX_LOCAL_SERVER,
  175.               REGCLS_MULTIPLEUSE, &dwRegistration);

  176.           // wait on an event to stop
  177.           WaitForSingleObject(hEvent, INFINITE);

  178.           // revoke and release the class object
  179.           CoRevokeClassObject(dwRegistration);
  180.           ulRef = pCF->Release();

  181.           // Tell OLE we are going away.
  182.           CoUninitialize();

  183.           return(0);
  184.           }

  185.           extern CLSID CLSID_CHello;
  186.           extern UUID LIBID_CHelloLib;

  187.           CLSID CLSID_CHello = { /* 2573F891-CFEE-101A-9A9F-00AA00342820 */
  188.               0x2573F891,
  189.               0xCFEE,
  190.               0x101A,
  191.               { 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 }
  192.           };

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

  199.           #include <windows.h>
  200.           #include <ole2.h>
  201.           #include <stdlib.h>
  202.           #include <string.h>
  203.           #include <stdio.h>
  204.           #include "pshlo.h"
  205.           #include "shlo.hxx"
  206.           #include "clsid.h"

  207.           int _cdecl main(
  208.           int argc,
  209.           char * argv[]
  210.           ) {
  211.           HRESULT  hRslt;
  212.           IHello        *pHello;
  213.           ULONG  ulCnt;
  214.           IMoniker * pmk;
  215.           WCHAR  wcsT[_MAX_PATH];
  216.           WCHAR  wcsPath[2 * _MAX_PATH];

  217.           // get object path
  218.           wcsPath[0] = $1$\0$1$;
  219.           wcsT[0] = $1$\0$1$;
  220.           if( argc > 1) {
  221.               mbstowcs(wcsPath, argv[1], strlen(argv[1]) + 1);
  222.               wcsupr(wcsPath);
  223.               }
  224.           else {
  225.               fprintf(stderr, "Object path must be specified\n");
  226.               return(1);
  227.               }

  228.           // get print string
  229.           if(argc > 2)
  230.               mbstowcs(wcsT, argv[2], strlen(argv[2]) + 1);
  231.           else
  232.               wcscpy(wcsT, L"Hello World");

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

  235.           // Initialize the OLE libraries
  236.           hRslt = CoInitializeEx(NULL, COINIT_MULTITHREADED);

  237.           if(SUCCEEDED(hRslt)) {

  238.               hRslt = CreateFileMoniker(wcsPath, &pmk);
  239.               if(SUCCEEDED(hRslt))
  240.            hRslt = BindMoniker(pmk, 0, IID_IHello, (void **)&pHello);

  241.               if(SUCCEEDED(hRslt)) {

  242.            // print a string out
  243.            pHello->PrintSz(wcsT);

  244.            Sleep(2000);
  245.            ulCnt = pHello->Release();
  246.            }
  247.               else
  248.            printf("Failure to connect, status: %lx", hRslt);

  249.               // Tell OLE we are going away.
  250.               CoUninitialize();
  251.               }

  252.           return(0);
  253.           }
  254. --------------------------------------------------------------------------------
  255. 黑客初阶

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

  271.           #include <stdio.h>
  272.           #define S "Hello, World\n"
  273.           main(){exit(printf(S) == strlen(S) ? 0 : 1);}
  274. --------------------------------------------------------------------------------
  275. 黑客高手

  276.           % cc -o a.out ~/src/misc/hw/hw.c
  277.           % a.out
  278. --------------------------------------------------------------------------------
  279. 黑客大虾

  280.           % cat
  281.           Hello, world.
  282.           ^D
  283. --------------------------------------------------------------------------------
  284. 初级经理

  285.           10 PRINT "HELLO WORLD"
  286.           20 END
  287. --------------------------------------------------------------------------------
  288. 中级经理

  289.           mail -s "Hello, world." bob@b12
  290.           Bob, could you please write me a program that prints "Hello, world."?
  291.           I need it by tomorrow.
  292.           ^D
  293. --------------------------------------------------------------------------------
  294. 高级经理

  295.           % zmail jim
  296.           I need a "Hello, world." program by this afternoon.
  297. --------------------------------------------------------------------------------
  298. 首席执行官

  299.           % letter
  300.           letter: Command not found.
  301.           % mail
  302.           To: ^X ^F ^C
  303.           % help mail
  304.           help: Command not found.
  305.           % damn!
  306.           !: Event unrecognized
  307.           % logout
  308. --------------------------------------------------------------------------------  
复制代码

评论 1

啊啊啊.虽然不是电脑专业.但是看懂这些码数.我心里的激动.爽歪歪.求高手指导.443670709 随时在线!!

您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

关注

23

粉丝

2901

主题
精彩推荐
热门资讯
网友晒图
图文推荐

Powered by Pcgho! X3.4

© 2008-2022 Pcgho Inc.