




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、代碼的幽默:“Hello World”的若干編寫方式作者簡(jiǎn)介:趙永華,男,威海職業(yè)學(xué)院信息工程系 高級(jí)工程師你是一名編程教師,學(xué)生上你的課特痛苦,他們抱怨說Coding枯燥乏味,此時(shí)你不妨讓他們?cè)囉靡幌氯缦戮帉憽癏ello WORLD”程序的不同方式。你就等著瞧好吧!中學(xué)生:10 PRINT "HELLO WORLD"20 END大一:program Hello(input, output)beginwriteln('Hello World')end.大學(xué)高年級(jí):(defun hello(print(cons 'Hello (list 'Wo
2、rld)見習(xí)程序員:#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等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 倉儲(chǔ)文員崗位面試問題及答案
- 采購總監(jiān)崗位面試問題及答案
- 2025屆廣東省廣州市廣東二師番禺附中化學(xué)高一下期末檢測(cè)模擬試題含解析
- 2025屆陜西省銅川市高二化學(xué)第二學(xué)期期末達(dá)標(biāo)檢測(cè)試題含解析
- 農(nóng)業(yè)監(jiān)督項(xiàng)目管理辦法
- 園區(qū)綠化養(yǎng)護(hù)管理辦法
- 醫(yī)保總額付費(fèi)管理辦法
- 保健食品銷售管理辦法
- 復(fù)合地層盾構(gòu)掘進(jìn)管線保護(hù)與地層加固優(yōu)化方案研究
- 家驢MRFs基因家族的全基因組鑒定與轉(zhuǎn)錄組學(xué)分析探究
- 2023-2024年全科醫(yī)學(xué)(正高)考試高頻題庫(歷年考點(diǎn)版)帶答案解析
- YY/T 0870.2-2019醫(yī)療器械遺傳毒性試驗(yàn)第2部分:體外哺乳動(dòng)物細(xì)胞染色體畸變?cè)囼?yàn)
- JJG 40-2011X射線探傷機(jī)
- GB/T 8923.1-2011涂覆涂料前鋼材表面處理表面清潔度的目視評(píng)定第1部分:未涂覆過的鋼材表面和全面清除原有涂層后的鋼材表面的銹蝕等級(jí)和處理等級(jí)
- GB/T 7778-2017制冷劑編號(hào)方法和安全性分類
- GB/T 4169.4-2006塑料注射模零件第4部分:帶頭導(dǎo)柱
- 天津2023年天津銀行信息技術(shù)崗招聘黑鉆模擬III試題3套含答案詳解
- 01-TOC約束理論(瓶頸管理)八講 作業(yè)
- 《國(guó)家學(xué)生體質(zhì)健康標(biāo)準(zhǔn)》登記卡(高中樣表)
- 靜脈炎的分級(jí)及護(hù)理課件
- 折讓證明模板
評(píng)論
0/150
提交評(píng)論