




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、代碼的幽默:“Hello World”的若干編寫方式作者簡介:趙永華,男,威海職業學院信息工程系 高級工程師你是一名編程教師,學生上你的課特痛苦,他們抱怨說Coding枯燥乏味,此時你不妨讓他們試用一下如下編寫“Hello WORLD”程序的不同方式。你就等著瞧好吧!中學生:10 PRINT HELLO WORLD20 END大一:program Hello(input, output)beginwriteln(Hello World)end.大學高年級:(defun hello(print(cons Hello (list World)見習程序員:#include void main(voi
2、d) char *message = Hello , World; int i; for(i = 0; i 2; +i) printf(%s, messagei); printf(n);資深程序員:#include #include class string private: int size; char *ptr; string() : size(0), ptr(new char1) ptr0 = 0; string(const string &s) : size(s.size) ptr = new charsize + 1; strcpy(ptr, s.ptr); string() del
3、ete 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 charsize + 1; strcpy(ptr, c
4、hrs); return(*this);int main() string str; str = Hello 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-101A-9A9F-0
5、0AA00342820) cotype THello interface IHello; interface IPersistFile; ;exe,uuid(2573F890-CFEE-101A-9A9F-00AA00342820)module CHelloLib / some code related header files importheader(); importheader(); importheader(); importheader(pshlo.h); importheader(shlo.hxx); importheader(mycls.hxx); / needed typel
6、ibs importlib(actimp.tlb); importlib(actexp.tlb); importlib(thlo.tlb); uuid(2573F891-CFEE-101A-9A9F-00AA00342820), aggregatable coclass CHello cotype THello; ;#include ipfix.hxxextern HANDLE hEvent;class CHello : public CHelloBase public: IPFIX(CLSID_CHello); CHello(IUnknown *pUnk); CHello(); HRESUL
7、T _stdcall PrintSz(LPWSTR pwszString); private: static int cObjRef;#include #include #include #include #include thlo.h#include pshlo.h#include shlo.hxx#include mycls.hxxint CHello:cObjRef = 0;CHello:CHello(IUnknown *pUnk) : CHelloBase(pUnk) cObjRef+; return;HRESULT _stdcall CHello:PrintSz(LPWSTR pws
8、zString) printf(%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 #include #include pshlo.h#include shlo.hxx#include mycls.hxxHANDLE hEvent;int _cdecl main(int argc
9、,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_CHello, pCF, CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE, &dwRegistratio
10、n); / 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); extern CLSID CLSID_CHello;extern UUID LIBID_CHelloLib;CLSID CLSID_CHello
11、= /* 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, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 ;#include #include #include #include #
12、include #include pshlo.h#include shlo.hxx#include clsid.hint _cdecl main(int argc,char * argv) HRESULT hRslt; 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) +
13、1); wcsupr(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, LHello World); printf(Linking to object %wsn, wcsPath); printf(Text String %wsn, wcsT); / Initialize the OLE libraries hRslt
14、 = 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) / print a string out pHello-PrintSz(wcsT); Sleep(2000); ulCnt = pHello-Release(); else printf
15、(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 Cant write $arg: $!n; print (FILE $msg); close(FILE) | die Cant close $arg: $!n; else print ($msg);1;老黑客:#include #define S Hello, Worldnmain()exit(printf(S) = strlen(S) ? 0 : 1);職業黑客:% cc -o a.out /src/misc/hw/hw.c% a.out大師級黑客:% echo Hello, world.行政小組長:10 PRINT HELLO WORLD20 END中層行政管理:mail -s Hello, world. bobb12Bob, could you please write
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- Fosfadecin-生命科學試劑-MCE
- 2025年工業互聯網平臺計算機視覺缺陷檢測技術在3C制造業中的應用報告
- 2025年智慧醫療建設與醫療資源優化配置研究報告
- 北京市大興區教育委員會所屬事業單位招聘教師考試真題2024
- 老舊小區改造背景下2025年居民功能改善滿意度分析報告
- GLI1-IN-3-生命科學試劑-MCE
- 電商綠色物流發展現狀與綠色物流技術創新成果轉化路徑報告2025年
- 2025至2030睡裙行業發展趨勢分析與未來投資戰略咨詢研究報告
- 2025至2030水產飼料補品行業發展趨勢分析與未來投資戰略咨詢研究報告
- 2025至2030智慧零售行業發展趨勢分析與未來投資戰略咨詢研究報告
- 【MOOC】算法初步-北京大學 中國大學慕課MOOC答案
- 食品檢驗員考試題庫單選題100道及答案解析
- 鄉鎮污水管道改造施工方案
- 四年級下冊道德與法治知識點
- 人工智能(AI)訓練師職業技能鑒定考試題及答案
- ASTM-D3359-(附著力測試標準)-中文版
- 全國中小學生學籍信息管理系統學生基本信息采集表(2022修訂版)
- CJT 211-2005 聚合物基復合材料檢查井蓋
- 云南省曲靖市2023-2024學年八年級下學期期末語文試題
- DZ∕T 0212.4-2020 礦產地質勘查規范 鹽類 第4部分:深藏鹵水鹽類(正式版)
- 借款利息確認書
評論
0/150
提交評論