您好,欢迎访问一九零五行业门户网

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

程序员
/*-------------------------------------------
程序员的进化--从学生到首席执行官
翻译 2002 王咏刚 http://www.contextfree.net/
转译自 omri\'s computer humor page
http://www.cs.bgu.ac.il/~omri/humor/
-------------------------------------------*/
--------------------------------------------------------------------------------
中学阶段
10 print \hello world\
20 end
--------------------------------------------------------------------------------
大学一年级
program hello(input, output)
begin
writeln(\'hello world\')
end.
--------------------------------------------------------------------------------
大学高年级
(defun hello
(print
(cons \'hello (list \'world))))
--------------------------------------------------------------------------------
初级程序员
#include
void main(void)
{
char *message[] = {\hello \, \world\};
int i;
for(i = 0; i printf(\%s\, message[i]);
printf(\\n\);
}
--------------------------------------------------------------------------------
编程老鸟
#include
#include
class string
{
private:
int size;
char *ptr;
public:
string() : size(0), ptr(new char(\'\0\')) {}
string(const string &s) : size(s.size)
{
ptr = new char[size + 1];
strcpy(ptr, s.ptr);
}
~string()
{
delete [] ptr;
}
friend ostream &operator string &operator=(const char *);
};
ostream &operator{
return(stream }
string &string::operator=(const char *chrs)
{
if (this != &chrs)
{
delete [] ptr;
size = strlen(chrs);
ptr = new char[size + 1];
strcpy(ptr, chrs);
}
return(*this);
}
int main()
{
string str;
str = \hello world\;
cout
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-00aa00342820)
]
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 typelibs
importlib(\actimp.tlb\);
importlib(\actexp.tlb\);
importlib(\thlo.tlb\);
[
uuid(2573f891-cfee-101a-9a9f-00aa00342820),
aggregatable
]
coclass chello
{
cotype thello;
};
};
#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
#include
#include
#include
#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)
{
printf(\%ws\n\, 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.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_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);
}
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, 0x9f, 0x00, 0xaa, 0x00, 0x34, 0x28, 0x20 }
};
#include
#include
#include
#include
#include
#include \pshlo.h\
#include \shlo.hxx\
#include \clsid.h\
int _cdecl main(
int argc,
char * argv[]
) {
hresult hrslt;
ihello *phello;
ulong ulcnt;
imoniker * pmk;
wchar wcst[_max_path];
wchar wcspath[2 * _max_path];
// get object path
wcspath[0] = \'\0\';
wcst[0] = \'\0\';
if( argc > 1) {
mbstowcs(wcspath, argv[1], strlen(argv[1]) + 1);
wcsupr(wcspath);
}
else {
fprintf(stderr, \object path must be specified\n\);
return(1);
}
// get print string
if(argc > 2)
mbstowcs(wcst, argv[2], strlen(argv[2]) + 1);
else
wcscpy(wcst, l\hello world\);
printf(\linking to object %ws\n\, wcspath);
printf(\text string %ws\n\, 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)) {
// 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\'t close $arg: $!\n\;
}
} else {
print ($msg);
}
1;
--------------------------------------------------------------------------------
黑客有成
#include
#define s \hello, world\n\
main(){exit(printf(s) == strlen(s) ? 0 : 1);}
--------------------------------------------------------------------------------
黑客高手
% cc -o a.out ~/src/misc/hw/hw.c
% a.out
--------------------------------------------------------------------------------
黑客大虾
% cat
hello, world.
^d
--------------------------------------------------------------------------------
初级经理
10 print \hello world\
20 end
--------------------------------------------------------------------------------
中级经理
mail -s \hello, world.\ bob@b12
bob, could you please write me a program that prints \hello, world.\?
i need it by tomorrow.
^d
--------------------------------------------------------------------------------
高级经理
% zmail jim
i need a \hello, world.\ program by this afternoon.
--------------------------------------------------------------------------------
首席执行官
% letter
letter: command not found.
% mail
to: ^x ^f ^c
% help mail
help: command not found.
% damn!
!: event unrecognized
% logout
--------------------------------------------------------------------------------
其它类似信息

推荐信息