| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2689 人关注过本帖
标题:[求助]T_T并非所有的代码路径都返回值是怎么回事??
只看楼主 加入收藏
yushengou
Rank: 1
等 级:新手上路
帖 子:401
专家分:0
注 册:2005-3-30
收藏
得分:0 
很强啊。
我想半天Main不知道该怎么写呢
所以才叫你全部贴出来的

我是初学者,希望大家能多多帮助我 /bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif');}" onmousewheel="return imgzoom(this);" alt="" />
2005-05-13 11:18
yushengou
Rank: 1
等 级:新手上路
帖 子:401
专家分:0
注 册:2005-3-30
收藏
得分:0 

using System;

namespace ConsoleApplication2 { /// <summary> /// Class1 的摘要说明。 /// </summary> class Class1 { /// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main(string[] args) { int sum=0; Console.WriteLine("判断积偶"); int n=int.Parse(Console.ReadLine()); if(n%2==1) { for(int a=1;a<=n;a+=2) { sum+=a; } Console.WriteLine("{0}",sum); } else { for(int b=2;b<=n;b+=2) { sum+=b; } Console.WriteLine("{0}",sum); } System.Threading.Thread.Sleep(1000); } }

} 我只能想出这样的来。

你那种思维我很想学的。

我是初学者,希望大家能多多帮助我 /bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif');}" onmousewheel="return imgzoom(this);" alt="" />
2005-05-13 11:29
单纯崇拜
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2005-5-11
收藏
得分:0 
.NET里边注解太多看的很晕
我都先在记事本里打遍在放到里面调

阿丫??签名不能用图片??
2005-05-13 11:47
yushengou
Rank: 1
等 级:新手上路
帖 子:401
专家分:0
注 册:2005-3-30
收藏
得分:0 
可以全删了再写嘛。

我是初学者,希望大家能多多帮助我 /bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif');}" onmousewheel="return imgzoom(this);" alt="" />
2005-05-13 11:58
live41
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:67
帖 子:12442
专家分:0
注 册:2004-7-22
收藏
得分:0 
以下是引用单纯崇拜在2005-5-13 10:46:30的发言: 呵呵,这样果然可以了 上面哪个直接return sum,为什么下面的if都不能执行呢?? 又没有跳出。。。。。。。
return是跳出函数,返回到调用函数的那里,你一开始跳出了函数的话,怎么执行下面的if语句啊!
2005-05-13 13:06
live41
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:67
帖 子:12442
专家分:0
注 册:2004-7-22
收藏
得分:0 
以下是引用单纯崇拜在2005-5-13 11:47:25的发言: .NET里边注解太多看的很晕 我都先在记事本里打遍在放到里面调
可以设置为不加注释的,具体在哪里设自己找找。
2005-05-13 13:07
单纯崇拜
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2005-5-11
收藏
得分:0 
以下是引用yushengou在2005-5-13 11:18:48的发言: 很强啊。 我想半天Main不知道该怎么写呢 所以才叫你全部贴出来的
方法单独声明出来 程序看起来会比较清楚 我也是刚这样的,感觉思路比以前有条理

阿丫??签名不能用图片??
2005-05-13 17:11
yichen
Rank: 1
等 级:新手上路
帖 子:303
专家分:0
注 册:2005-3-9
收藏
得分:0 
以下是引用单纯崇拜在2005-5-13 11:47:25的发言: .NET里边注解太多看的很晕 我都先在记事本里打遍在放到里面调
那么多的注释, 是为了方便 自己,还有别人看的阿 !

衣带渐宽终不悔, 为伊消得人憔悴。 纸上得来终觉浅, 绝知此事要躬行。
2005-05-14 20:33
幻风幻云
Rank: 1
等 级:新手上路
帖 子:762
专家分:0
注 册:2005-1-14
收藏
得分:0 
以下是引用yushengou在2005-5-13 11:18:48的发言: 很强啊。 我想半天Main不知道该怎么写呢 所以才叫你全部贴出来的
你 你 你…… 上次给别人说 方法单独写出来,main函数中只调用,你还写了个例子出来,现在又忘了啊?

2005-05-14 23:37
快速回复:[求助]T_T并非所有的代码路径都返回值是怎么回事??
数据加载中...
 
   



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

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