有道简单的题目:用一维数组接收用户输入的任意N个自然数,并用for循环语句来实现求和.
请告诉怎么做?
请告诉怎么做?
解决方案 »
- winform打包,安装到2个路径
- 怎样实现类似OutLook的导航条
- 我刚接触C++根本外行,按方案表格填了其中张xml_interface.cpp出错,已经搞头晕,求教诸师 不胜感激!望那位师加我Q139160578以后能酬教
- 关于WinForm里的DataGrid排序的问题
- 关于“System.ArgumentException: 转换缓冲区溢处.”异常该如何解决?
- 谁有Genie.acs、Robby.acs、Merlin.acs和peedy.acs,无法在微软网站下载,谢谢谢!
- 求asp开发的论坛源代码 数据库用SqlServer 2000的
- 把一个项目从vs2003升级到vs2005中碰到的问题?
- 重分求数据交叉问题
- 求救!
- C# Winform中TreeView的问题
- MainMenu主菜单,MenuItem.Enabled =true/false的问题!
char ans='y';
int result=0;
while(ans='y' || ans='Y')
{
try
{
int temp=int.Parse(Console.ReadLine());
Console.Write("是否继续(Y/N)?");
ans=char.Parse(Console.ReadLine());
}
}
for(int i=0;i<ary.Count;i++)
{
result+=ary[i];
}
Console.WriteLine(result);
}
Catch( Exception e)
{
Console.WriteLine(e.Message);
}
System.Collections.ArrayList ary=new System.Collections.ArrayList();
char ans='y';
int result=0;
while(ans='y' || ans='Y')
{
try
{
int temp=int.Parse(Console.ReadLine());
ary.add(temp);//先把数据放进去,然后再取出来
Console.Write("是否继续(Y/N)?");
ans=char.Parse(Console.ReadLine());
}
}
for(int i=0;i<ary.Count;i++)
{
result+=ary[i];
}
Console.WriteLine(result);
}
Catch( Exception e)
{
Console.WriteLine(e.Message);
}
char ans = 'y';
int result = 0;
try
{
while (ans == 'y' || ans == 'Y')
{ int temp = int.Parse(Console.ReadLine());
ary.Add(temp);//先把数据放进去,然后再取出来
Console.Write("是否继续(Y/N)?");
ans = char.Parse(Console.ReadLine()); } for (int i = 0; i < ary.Count; i++)
{
result += (int)ary[i];
} Console.WriteLine(result.ToString());
} catch (Exception e)
{
Console.WriteLine(e.Message);
}