Programming 版 (精华区)

发信人: Scorpion (但教心似金钿坚), 信区: Programming
标  题: [合集]来看看这个Hello World程序
发信站: 哈工大紫丁香 (2002年03月28日09:46:22 星期四), 站内信件

发信人: Scorpion (The Sky's Limit!), 信区: Programming
标  题: 来看看这个Hello World程序
发信站: 哈工大紫丁香 (2001年05月03日23:25:41 星期四), 站内信件


偶然看到的,保存为*.c文件在VC6.0下编译通过。

int i;
main(){for(;i["]<i;++i){--i;}"];read('-'-'-',i+++"hello, world!\n",'/'/'/'))
;}
read(j,i,p){write(j/p+p,i---j,i/i);}

这是1984年IOCCC(www.ioccc.org)获将作品,
ioccc(International Obfuscated C Code Contest ) 比赛的目的就是编出可读性很差
代码很能迷惑人,结果最出乎意料,最短小精悍的程序! 研究一下,很有意思的。
--

※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: mtlab5.hit.edu.cn]
※ 修改:·Scorpion 於 05月03日23:28:14 修改本文·[FROM: mtlab5.hit.edu.cn]
发信人: Scorpion (The Sky's Limit!), 信区: Programming
标  题: Re: 来看看这个Hello World程序
发信站: 哈工大紫丁香 (2001年05月04日10:01:13 星期五), 站内信件

其实我也是看了CSDN上的帖子才明白的:
http://www.csdn.net/expert/topic/110/110221.shtm

A[B],有两种合法的解释,第一就是大家熟悉的,不说了,第二是: A 是下标,B是数组
!!!
所以 i["]<i;++i){--i;}"],其实就是字符串数组 "]<i;++i){--i;}" 中第i个元素的字
符!!
我也是第一次知道C的这种用法。
这样应该这样整理才对:
main()
{
    for(;
    i["]<i;++i){--i;}"];
    read('-'-'-',i+++"hello, world!\n",'/'/'/'));
}
read(j,i,p)
{
    write(j/p+p,i---j,i/i);
}

我还是不明白'-'-'-'怎么作为参数传递的。

【 在 lofe (〖老夫·为七月奋斗〗) 的大作中提到: 】
: 整理了一下,但还是不懂:
: int i;
: main(){
:     for(;i["]<i;++i){
:         --i;
:     }"];

:     read('-'-'-',i+++"hello, world!\n",'/'/'/'));

--

※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: mtlab5.hit.edu.cn]
发信人: zhangyan (塑料脑袋镀浆糊), 信区: Programming
标  题: Re: 来看看这个Hello World程序
发信站: 哈工大紫丁香 (2001年05月04日10:07:00 星期五), 站内信件

faint 还有这种用法?
'-'-'-'就是0吧?
'-' - '-'

【 在 Scorpion (The Sky's Limit!) 的大作中提到: 】
: 其实我也是看了CSDN上的帖子才明白的:
: http://www.csdn.net/expert/topic/110/110221.shtm
: A[B],有两种合法的解释,第一就是大家熟悉的,不说了,第二是: A 是下标,B是数组
: !!!
: 所以 i["]<i;++i){--i;}"],其实就是字符串数组 "]<i;++i){--i;}" 中第i个元素的字
: 符!!
: 我也是第一次知道C的这种用法。
: 这样应该这样整理才对:
: main()

--
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 天外飞仙]
发信人: zhangyan (塑料脑袋镀浆糊), 信区: Programming
标  题: Re: 来看看这个Hello World程序
发信站: 哈工大紫丁香 (2001年05月04日10:10:34 星期五), 站内信件

第一个是减法 '-'减去'-'所以是0
第二个是除法 '/'除以'/'所以是1
【 在 Scorpion (The Sky's Limit!) 的大作中提到: 】
: why?????
: 为什么就是0就是1
: 【 在 zhangyan (塑料脑袋镀浆糊) 的大作中提到: 】
: : '/'/'/'就是1

--
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 天外飞仙]
发信人: ssos (存在与虚无), 信区: Programming
标  题: Re: 来看看这个Hello World程序
发信站: 哈工大紫丁香 (2001年05月04日10:21:36 星期五), 站内信件

关键是read中的write函数的参数的含义是什么
这个函数我从来没有用过的
【 在 zhangyan (塑料脑袋镀浆糊) 的大作中提到: 】
: 可是i++ +"hello world"是什么?
: 【 在 Scorpion (The Sky's Limit!) 的大作中提到: 】
: : My God!!!!!!!!!
: : 明白了,笑死我了,怎么也没想到呀!!!!!!!!
: : 服了。
: : 第一个是减法 '-'减去'-'所以是0
: : 第二个是除法 '/'除以'/'所以是1

--

   
<<社会契约论>>是一本好书,应当多读几遍
风味的肘子味道不错,我还想再吃它      

※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: as.hit.edu.cn]
发信人: lofe (〖老夫·为七月奋斗〗), 信区: Programming
标  题: Re: 来看看这个Hello World程序
发信站: 哈工大紫丁香 (2001年05月04日10:25:57 星期五), 站内信件

read: reads from a file

int read(int handle, void *buf, unsigned len);

Prototype in io.h

Upon successful completion, it returns an
integer indicating the number of bytes placed
in the buffer; if the file was opened in text
mode, read does not count carriage returns or
Ctrl-Z characters in the number of bytes read.
On error, it returns -1 and sets errno.

See also     _read   open   write

不理解 read(i,j,p)这个里面没有类型说明的参数是怎么混过去的

【 在 ssos (存在与虚无) 的大作中提到: 】
: 关键是read中的write函数的参数的含义是什么
: 这个函数我从来没有用过的
: 【 在 zhangyan (塑料脑袋镀浆糊) 的大作中提到: 】
: : 可是i++ +"hello world"是什么?

--
直到有一天,
你看淡了一切,
觉得这些是人生来来往往中的一部分,
都是美丽的,
你就悟了。

※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: DnC.hit.edu.cn]
发信人: zhangyan (塑料脑袋镀浆糊), 信区: Programming
标  题: Re: 来看看这个Hello World程序
发信站: 哈工大紫丁香 (2001年05月04日10:26:37 星期五), 站内信件

原来的C不需要函数原型 当然可以混过去了
【 在 lofe (〖老夫·为七月奋斗〗) 的大作中提到: 】
: read: reads from a file
: int read(int handle, void *buf, unsigned len);
: Prototype in io.h
: Upon successful completion, it returns an
: integer indicating the number of bytes placed
: in the buffer; if the file was opened in text
: mode, read does not count carriage returns or
: Ctrl-Z characters in the number of bytes read.

--
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 天外飞仙]
发信人: lofe (〖老夫·为七月奋斗〗), 信区: Programming
标  题: Re: 来看看这个Hello World程序
发信站: 哈工大紫丁香 (2001年05月04日10:33:07 星期五), 站内信件

现在的c编译器也能混过去呀
而且在read中的j,i,p是什么东西,没声明/定义,怎么就能用了

【 在 zhangyan (塑料脑袋镀浆糊) 的大作中提到: 】
: 原来的C不需要函数原型 当然可以混过去了
: 【 在 lofe (〖老夫·为七月奋斗〗) 的大作中提到: 】
: : read: reads from a file
: : int read(int handle, void *buf, unsigned len);
: : Prototype in io.h
: : Upon successful completion, it returns an
: : integer indicating the number of bytes placed
: : in the buffer; if the file was opened in text
: : mode, read does not count carriage returns or
: : Ctrl-Z characters in the number of bytes read.

--
直到有一天,
你看淡了一切,
觉得这些是人生来来往往中的一部分,
都是美丽的,
你就悟了。

※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: DnC.hit.edu.cn]
发信人: lofe (〖老夫·为七月奋斗〗), 信区: Programming
标  题: Re: 来看看这个Hello World程序
发信站: 哈工大紫丁香 (2001年05月04日10:45:08 星期五), 站内信件

read的第二个参数类型是 char*

C/C++中"hello world.\n"这样的常量字符串实际被处理成char*指针了,因此

i++ + "hello world.\n"就是常量字符串首地址+偏移(i++)

【 在 zhangyan (塑料脑袋镀浆糊) 的大作中提到: 】
: 可是i++ +"hello world"是什么?
: 【 在 Scorpion (The Sky's Limit!) 的大作中提到: 】
: : My God!!!!!!!!!
: : 明白了,笑死我了,怎么也没想到呀!!!!!!!!
: : 服了。
: : 第一个是减法 '-'减去'-'所以是0
: : 第二个是除法 '/'除以'/'所以是1

--
直到有一天,
你看淡了一切,
觉得这些是人生来来往往中的一部分,
都是美丽的,
你就悟了。

※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: DnC.hit.edu.cn]
※ 修改:·lofe 於 05月04日10:50:28 修改本文·[FROM: DnC.hit.edu.cn]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.281毫秒