可爱的hello world
黑客组吧
全部回复
仅看楼主
level 2
转自豆瓣
2011年11月03日 13点11分 1
level 2
不同年龄职业的人所写的Hello World程序
高中(BASIC)
10 PRINT "HELLO WORLD"
20 END
大一(PASCAL)
program Hello(input, output)
begin
writeln('Hello World')
end.
大二以后(LISP)
(defun hello
(print
(cons 'Hello (list 'World))))
职场新人(C)
#include <stdio.h>
void main(void)
{
char *message[] = {"Hello ", "World"};
int i;
for(i = 0; i < 2; ++i)
printf("%s", message[i]);
printf("\n");
}
职场老手(C++)
#include <iostream.h>
#include <string.h>
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 <<(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 char[size + 1];
strcpy(ptr, chrs);
}
return(*this);
}
int main()
{
string str;
str = "Hello World";
cout << str << endl;
return(0);
}
2011年11月03日 14点11分 6
level 2
学徒黑客(Perl)
#!/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;
2011年11月03日 14点11分 10
level 2
这贴被吞的差不多了。百度是想怎样啊。
2011年11月05日 16点11分 12
level 11
度娘心情不好
2011年11月06日 00点11分 13
level 6
echo "Hello World!"
2012年01月11日 13点01分 14
level 5
目测....我在职场新人阶段,至少程序是这样的。哈哈!
2012年01月11日 13点01分 15
level 11
哇~~~我写那个就几句就完了~~~嘎嘎~~哪还用啥for喔~~~
2012年01月11日 15点01分 16
level 5
[瞌睡]
2012年01月12日 06点01分 18
1