Ken Thompson 的经典 C 程序

 char s[]={
'\t',
'0',
'\n',
'}',
';',
'\n',
'\n',
'm',
'a',
'i',
'n',
'(',
')',
'\n',
'{',
'\n',
'\t',
'i',
'n',
't',
' ',
'i',
';',
'\n',
'\n',
'\t',
'p',
'r',
'i',
'n',
't',
'f',
'(',
'"',
'c',
'h',
'a',
'r',
' ',
's',
'[',
']',
'=',
'{',
'\\',
'n',
'"',
')',
';',
'\n',
'\t',
'f',
'o',
'r',
'(',
'i',
'=',
'0',
';',
' ',
's',
'[',
'i',
']',
';',
' ',
'i',
'+',
'+',
')',
'\n',
'\t',
'\t',
'p',
'r',
'i',
'n',
't',
'f',
'(',
'"',
'\\',
't',
'%',
'd',
',',
'\\',
'n',
'"',
',',
's',
'[',
'i',
']',
')',
';',
'\n',
'\t',
'p',
'r',
'i',
'n',
't',
'f',
'(',
'"',
'%',
's',
'"',
',',
's',
')',
';',
'\n',
'}',
'\n',
0
}
;

main()
{
int i;

printf(
"char s[]={\n");
for(i=0; s[i]; i++)
printf(
"\t%d,\n",s[i]);
printf(
"%s",s);
}



============输出结果===============

char s[]={
9,
48,
10,
125,
59,
10,
10,
109,
97,
105,
110,
40,
41,
10,
123,
10,
9,
105,
110,
116,
32,
105,
59,
10,
10,
9,
112,
114,
105,
110,
116,
102,
40,
34,
99,
104,
97,
114,
32,
115,
91,
93,
61,
123,
92,
110,
34,
41,
59,
10,
9,
102,
111,
114,
40,
105,
61,
48,
59,
32,
115,
91,
105,
93,
59,
32,
105,
43,
43,
41,
10,
9,
9,
112,
114,
105,
110,
116,
102,
40,
34,
92,
116,
37,
100,
44,
92,
110,
34,
44,
115,
91,
105,
93,
41,
59,
10,
9,
112,
114,
105,
110,
116,
102,
40,
34,
37,
115,
34,
44,
115,
41,
59,
10,
125,
10,
0
}
;

main()
{
int i;

printf(
"char s[]={\n");
for(i=0; s[i]; i++)
printf(
"\t%d,\n",s[i]);
printf(
"%s",s);
}

posted @ 2008-05-13 08:51  CoderZh  阅读(3587)  评论(2编辑  收藏  举报