标题:我的程序 不止到错到那里!!
取消只看楼主
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



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-15420-1-1.html




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

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