| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 772 人关注过本帖
标题:我的程序 不止到错到那里!!
取消只看楼主 加入收藏
zhangfeng
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2005-3-20
收藏
 问题点数:0 回复次数:1 
我的程序 不止到错到那里!!

using System; public class nan { public int Sum(int[] list) { int all=0; foreach(int c in list) { all+=c; } return all; } static void Main() {

Console.WriteLine("请输入你需要0~~100的数的个数:"); int n=int.Parse(Console.ReadLine());

for(int a=0;a<=n;a++)//a从0到n,总共有n+1个数 { int i=0; Console.WriteLine("请输入你需要0~~100的数的+a+:"); int c=int.Parse(Console.ReadLine()); nan p=new nan(); int[] text=new int [n]; text[i]=c; int all = p.Sum(text);//Sum里面含有foreach语句,又在for语句中,循环了多少次啊?你自己算算 if(a==n) { Console.WriteLine(all); } else { continue; } } System.Threading.Thread.Sleep(10000); }

}

[此贴子已经被幻风幻云于2005-4-12 23:28:57编辑过]

搜索更多相关主题的帖子: return public color 
2005-04-11 21:45
zhangfeng
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2005-3-20
收藏
得分:0 
我的目的是想设置一个可变的数组  想向里面输入几个数就输入几个数!最后得到他们的和!
2005-04-12 15:33
快速回复:我的程序 不止到错到那里!!
数据加载中...
 
   



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

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