| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 48911 人关注过本帖, 10 人收藏
标题:[全民编程]76道高难度C++练习题.含NOI竞赛题.欢迎挑战
只看楼主 加入收藏
野比
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:1627
专家分:516
注 册:2007-5-24
收藏
得分:0 
回复:(jiaju111)//第16题代码;//完全是按顺序编写...
jiaju111兄... 很明显题目是要遍历各种情况...不是自己输入..

女侠,约吗?
2007-06-18 20:06
野比
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:1627
专家分:516
注 册:2007-5-24
收藏
得分:0 
回复:(aipb2007) 11. 巧排数字。将1、2、......
aipb2007兄,.. 你的int main忘返回值了... 提醒一下

女侠,约吗?
2007-06-18 20:14
野比
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:1627
专家分:516
注 册:2007-5-24
收藏
得分:0 
大家验证一下HJin关于第75题的解答吧.. 我持保留意见.. (没有完全按照题干作答)..

女侠,约吗?
2007-06-18 20:26
aipb2007
Rank: 8Rank: 8
来 自:CQU
等 级:贵宾
威 望:40
帖 子:2879
专家分:7
注 册:2007-3-18
收藏
得分:0 
以下是引用野比在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-06-18 20:27
野比
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:1627
专家分:516
注 册:2007-5-24
收藏
得分:0 
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-06-18 20:40
aipb2007
Rank: 8Rank: 8
来 自:CQU
等 级:贵宾
威 望:40
帖 子:2879
专家分:7
注 册:2007-3-18
收藏
得分:0 


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

Fight  to win  or  die...
2007-06-18 21:08
野比
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:1627
专家分:516
注 册:2007-5-24
收藏
得分:0 
当然, 这是个习惯问题..
就像我常写 void main 这种剑走偏锋的路子...

ps. VC编译会有warning的...对于任何没有返回的非void函数...

女侠,约吗?
2007-06-18 21:18
aipb2007
Rank: 8Rank: 8
来 自:CQU
等 级:贵宾
威 望:40
帖 子:2879
专家分:7
注 册:2007-3-18
收藏
得分:0 
vc++6.0有太多bug和非标准行为了,我不喜欢它.
偶用vs2005!

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


Fight  to win  or  die...
2007-06-18 21:39
野比
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:1627
专家分:516
注 册:2007-5-24
收藏
得分:0 
我的VC2005无法include! 为啥? 我就太阳了...

女侠,约吗?
2007-06-18 21:52
bluebell
Rank: 1
等 级:新手上路
帖 子:102
专家分:0
注 册:2007-5-14
收藏
得分:0 

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

[b][u]你说我容易吗?????[/u][/b]
2007-06-18 23:01
快速回复:[全民编程]76道高难度C++练习题.含NOI竞赛题.欢迎挑战
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017434 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved