| 编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛
全能ASP/PHP/ASP.NET主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付买域名,送MP3、MP4
高端软件开发 = 年薪十万不是梦赛孚耐:软件保护加密专家身份认证令牌USB KEY买空间,免费送域名(厦门中资源)
共有 32034 人关注过本帖
标题:[全民编程]76道高难度C++练习题.含NOI竞赛题.欢迎挑战
收藏  订阅  推荐  打印 
野比
Rank: 12Rank: 12Rank: 12
等级:贵宾
威望:14
帖子:990
积分:10576
注册:2007-5-24
回复:(jiaju111)//第16题代码;//完全是按顺序编写...

jiaju111兄... 很明显题目是要遍历各种情况...不是自己输入..
2007-6-18 20:06
野比
Rank: 12Rank: 12Rank: 12
等级:贵宾
威望:14
帖子:990
积分:10576
注册:2007-5-24
回复:(aipb2007) 11. 巧排数字。将1、2、......

aipb2007兄,.. 你的int main忘返回值了... 提醒一下
2007-6-18 20:14
野比
Rank: 12Rank: 12Rank: 12
等级:贵宾
威望:14
帖子:990
积分:10576
注册:2007-5-24

大家验证一下HJin关于第75题的解答吧.. 我持保留意见.. (没有完全按照题干作答)..
2007-6-18 20:26
aipb2007
Rank: 12Rank: 12Rank: 12
来自:CQU
等级:贵宾
威望:40
帖子:2881
积分:29414
注册:2007-3-18

以下是引用野比在2007-6-18 20:14:36的发言:
aipb2007兄,.. 你的int main忘返回值了... 提醒一下

Can I write "void main()"?
The definition
void main() { /* ... */ }

is not and never has been C++, nor has it even been C. See the ISO C++ standard 3.6.1[2] or the ISO C standard 5.1.2.2.1. A conforming implementation accepts
int main() { /* ... */ }

and
int main(int argc, char* argv[]) { /* ... */ }

A conforming implementation may provide more versions of main(), but they must all have return type int. The int returned by main() is a way for a program to return a value to "the system" that invokes it. On systems that doesn't provide such a facility the return value is ignored, but that doesn't make "void main()" legal C++ or legal C. Even if your compiler accepts "void main()" avoid it, or risk being considered ignorant by C and C++ programmers.
In C++, main() need not contain an explicit return statement. In that case, the value returned is 0, meaning successful execution. For example:

#include<iostream>

int main()
{
std::cout << "This program returns the integer value 0\n";
}

Note also that neither ISO C++ nor C99 allows you to leave the type out of a declaration. That is, in contrast to C89 and ARM C++ ,"int" is not assumed where a type is missing in a declaration. Consequently:
#include<iostream>

main() { /* ... */ }

is an error because the return type of main() is missing.

摘自c++之父BJ大叔的FAQ。
请看红色部分

Fight  to win  or  die...
2007-6-18 20:27
野比
Rank: 12Rank: 12Rank: 12
等级:贵宾
威望:14
帖子:990
积分:10576
注册:2007-5-24

NEED not 不是 SHOULD not.. 也不是 BETTER not...
ISO/IEC 14882上面是这么说的:
If control reaches the end of main without encountering a return statement, the effect is that of executing
return 0;

但是谁又能保证看到这段代码的人都知道这个呢?
2007-6-18 20:40
aipb2007
Rank: 12Rank: 12Rank: 12
来自:CQU
等级:贵宾
威望:40
帖子:2881
积分:29414
注册:2007-3-18



写习惯了,管他的,既然允许能少写点就少写点吧!
有人要编译那代码,也不会报错的。

Fight  to win  or  die...
2007-6-18 21:08
野比
Rank: 12Rank: 12Rank: 12
等级:贵宾
威望:14
帖子:990
积分:10576
注册:2007-5-24

当然, 这是个习惯问题..
就像我常写 void main 这种剑走偏锋的路子...

ps. VC编译会有warning的...对于任何没有返回的非void函数...
2007-6-18 21:18
aipb2007
Rank: 12Rank: 12Rank: 12
来自:CQU
等级:贵宾
威望:40
帖子:2881
积分:29414
注册:2007-3-18

vc++6.0有太多bug和非标准行为了,我不喜欢它.
偶用vs2005!

[此贴子已经被作者于2007-6-18 21:45:35编辑过]


Fight  to win  or  die...
2007-6-18 21:39
野比
Rank: 12Rank: 12Rank: 12
等级:贵宾
威望:14
帖子:990
积分:10576
注册:2007-5-24

我的VC2005无法include! 为啥? 我就太阳了...
2007-6-18 21:52
bluebell
Rank: 2
等级:注册会员
帖子:102
积分:1136
注册:2007-5-14


希望我自己完成的那天早些到来
^_^

[b][u]你说我容易吗?????[/u][/b]
2007-6-18 23:01
关于我们 | 广告合作 | 编程中国 | 清除Cookies | Archiver | WAP | TOP

编程中国 版权所有,并保留所有权利。鲁ICP备08000592号
Powered by Discuz, Processed in 0.056438 second(s), 9 queries.
Copyright©2004-2008, BCCN.NET, All Rights Reserved