![hello_world_代碼的幽默_第1頁](http://file3.renrendoc.com/fileroot_temp3/2022-1/16/a601b1fb-be96-4b58-b48b-18578f28919b/a601b1fb-be96-4b58-b48b-18578f28919b1.gif)
![hello_world_代碼的幽默_第2頁](http://file3.renrendoc.com/fileroot_temp3/2022-1/16/a601b1fb-be96-4b58-b48b-18578f28919b/a601b1fb-be96-4b58-b48b-18578f28919b2.gif)
![hello_world_代碼的幽默_第3頁](http://file3.renrendoc.com/fileroot_temp3/2022-1/16/a601b1fb-be96-4b58-b48b-18578f28919b/a601b1fb-be96-4b58-b48b-18578f28919b3.gif)
![hello_world_代碼的幽默_第4頁](http://file3.renrendoc.com/fileroot_temp3/2022-1/16/a601b1fb-be96-4b58-b48b-18578f28919b/a601b1fb-be96-4b58-b48b-18578f28919b4.gif)
![hello_world_代碼的幽默_第5頁](http://file3.renrendoc.com/fileroot_temp3/2022-1/16/a601b1fb-be96-4b58-b48b-18578f28919b/a601b1fb-be96-4b58-b48b-18578f28919b5.gif)
版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
1、代碼的幽默:“Hello World”的若干編寫方式作者簡介:趙永華,男,威海職業(yè)學院信息工程系 高級工程師你是一名編程教師,學生上你的課特痛苦,他們抱怨說Coding枯燥乏味,此時你不妨讓他們試用一下如下編寫“Hello WORLD”程序的不同方式。你就等著瞧好吧!中學生:10 PRINT "HELLO WORLD"20 END大一:program Hello(input, output)beginwriteln('Hello World')end.大學高年級:(defun hello(print(cons 'Hello (list 'Wo
2、rld)見習程序員:#include <stdio.h>void main(void) char *message = "Hello ", "World" int i; for(i = 0; i < 2; +i) printf("%s", messagei); printf("n");資深程序員:#include <iostream.h>#include <string.h>class string private: int size; char *ptr; string(
3、) : size(0), ptr(new char1) ptr0 = 0; string(const string &s) : size(s.size) ptr = new charsize + 1; strcpy(ptr, s.ptr); string() delete ptr; friend ostream &operator <<(ostream &, const string &); string &operator=(const char *);ostream &operator<
4、;<(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 charsize + 1; strcpy(ptr, chrs); return(*this);int main() string str; str = "He
5、llo World" cout << str << endl; return(0);程序員頭目:uuid(2573F8F4-CFEE-101A-9A9F-00AA00342820)library LHello / bring in the master library importlib("actimp.tlb"); importlib("actexp.tlb"); / bring in my interfaces #include "pshlo.idl" uuid(2573F8F5-CFEE-101
6、A-9A9F-00AA00342820) cotype THello interface IHello; interface IPersistFile; ;exe,uuid(2573F890-CFEE-101A-9A9F-00AA00342820)module CHelloLib / some code related header files importheader(<windows.h>); importheader(<ole2.h>); importheader(<except.hxx>); importheader(&qu
7、ot;pshlo.h"); importheader("shlo.hxx"); importheader("mycls.hxx"); / needed typelibs importlib("actimp.tlb"); importlib("actexp.tlb"); importlib("thlo.tlb"); uuid(2573F891-CFEE-101A-9A9F-00AA00342820), aggregatable coclass CHello cotype T
8、Hello; ;#include "ipfix.hxx"extern HANDLE hEvent;class CHello : public CHelloBase public: IPFIX(CLSID_CHello); CHello(IUnknown *pUnk); CHello(); HRESULT _stdcall PrintSz(LPWSTR pwszString); private: static int cObjRef;#include <windows.h>#include <ole2.h>#include <stdi
9、o.h>#include <stdlib.h>#include "thlo.h"#include "pshlo.h"#include "shlo.hxx"#include "mycls.hxx"int CHello:cObjRef = 0;CHello:CHello(IUnknown *pUnk) : CHelloBase(pUnk) cObjRef+; return;HRESULT _stdcall CHello:PrintSz(LPWSTR pwszString) pr
10、intf("%ws ", pwszString); return(ResultFromScode(S_OK);CHello:CHello(void) / when the object count goes to zero, stop the server cObjRef-; if( cObjRef = 0 ) PulseEvent(hEvent); return;#include <windows.h>#include <ole2.h>#include "pshlo.h"#include "shlo.hxx"
11、#include "mycls.hxx"HANDLE hEvent;int _cdecl main(int argc,char * argv) ULONG ulRef; DWORD dwRegistration; CHelloCF *pCF = new CHelloCF(); hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); / Initialize the OLE libraries CoInitializeEx(NULL, COINIT_MULTITHREADED); CoRegisterClassObject(CLSID_
12、CHello, pCF, CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE, &dwRegistration); / wait on an event to stop WaitForSingleObject(hEvent, INFINITE); / revoke and release the class object CoRevokeClassObject(dwRegistration); ulRef = pCF->Release(); / Tell OLE we are going away. CoUninitialize(); return(0
13、); extern CLSID CLSID_CHello;extern UUID LIBID_CHelloLib;CLSID CLSID_CHello = /* 2573F891-CFEE-101A-9A9F-00AA00342820 */ 0x2573F891, 0xCFEE, 0x101A, 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 ;UUID LIBID_CHelloLib = /* 2573F890-CFEE-101A-9A9F-00AA00342820 */ 0x2573F890, 0xCFEE, 0x101A, 0x9A, 0x9
14、F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 ;#include <windows.h>#include <ole2.h>#include <stdlib.h>#include <string.h>#include <stdio.h>#include "pshlo.h"#include "shlo.hxx"#include "clsid.h"int _cdecl main(int argc,char * argv) HRESULT h
15、Rslt; IHello *pHello; ULONG ulCnt; IMoniker * pmk; WCHAR wcsT_MAX_PATH; WCHAR wcsPath2 * _MAX_PATH; / get object path wcsPath0 = '0' wcsT0 = '0' if( argc > 1) mbstowcs(wcsPath, argv1, strlen(argv1) + 1); wcsu
16、pr(wcsPath); else fprintf(stderr, "Object path must be specifiedn"); return(1); / get print string if(argc > 2) mbstowcs(wcsT, argv2, strlen(argv2) + 1); else wcscpy(wcsT, L"Hello World"); printf("Linking to object %wsn", wcsPath); printf("Text Stri
17、ng %wsn", wcsT); / Initialize the OLE libraries hRslt = CoInitializeEx(NULL, COINIT_MULTITHREADED); if(SUCCEEDED(hRslt) hRslt = CreateFileMoniker(wcsPath, &pmk); if(SUCCEEDED(hRslt) hRslt = BindMoniker(pmk, 0, IID_IHello, (void *)&pHello); if(SUCCEEDED(hRslt)
18、160; / print a string out pHello->PrintSz(wcsT); Sleep(2000); ulCnt = pHello->Release(); else printf("Failure to connect, status: %lx", hRslt); / Tell OLE we are going away. CoUninitialize(); return(0);新黑客:#!/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
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 七年級數(shù)學上冊第30課時銷售問題和儲蓄問題聽評課記錄新湘教版
- 湘教版數(shù)學八年級上冊《1.1 分式》聽評課記錄
- 人教版歷史七年級下冊第1課《隋朝的統(tǒng)一與滅亡》聽課評課記錄
- 2022年新課標八年級上冊道德與法治《7.1 關愛他人 》聽課評課記錄
- 生物技術創(chuàng)新合作開發(fā)合同(2篇)
- 理財委托合同(2篇)
- 人教版數(shù)學八年級下冊20.1.1《平均數(shù)》聽評課記錄3
- 語文聽評課記錄九年級
- 人教版數(shù)學八年級上冊《11.2.2三角形的外角》聽評課記錄1
- 數(shù)學七年級下學期《立方根》聽評課記錄
- 大美陜西歡迎你-最全面的陜西省簡介課件
- 三位數(shù)減三位數(shù)的減法計算題 200道
- 米粉項目可行性研究報告
- 人教版九年級英語全冊期末復習完成句子專項練習
- 蛇年元宵節(jié)燈謎大全(附答案)
- 2023年上海中僑職業(yè)技術大學單招考試職業(yè)技能考試模擬試題及答案解析
- 中國教育公益領域發(fā)展報告
- 第2章第1節(jié)有機化學反應類型課件高二下學期化學魯科版選擇性必修3
- 生物質(zhì)能利用原理與技術 - 第二章生物質(zhì)能資源與植物
- 校本課程《竹之匠藝》
- 栽植土檢驗批質(zhì)量驗收記錄
評論
0/150
提交評論