写一个程序,找出输入的一连串整数的最大最小值。程序首先应提醒用户指定要输入多少个值。接着打印这个值,并要求用户确认。如果用户没有对这个值进行确认,就必须输入一个新的值。
如何编写上述程序
C#语言.
如何编写上述程序
C#语言.
解决方案 »
- 查找某一页面外链个数
- 怎么把listview控件与imagelist控件结合起来显示图片
- 急救 小球脱离主窗体,单独在桌面上显示,困了我很久的,各位弟兄多多帮忙,兄弟先行谢过!
- 有没有精美的3D按钮代码?
- 请教一个GDI+画图时候产生大量误差的解决方法
- C#中如何取得网吧内网的IP地址?
- 请问通过CCProxy代理上网的机器如何访问Internet上的SQL Server,up 有分!
- .net中有没有解码数字证书的类啊??
- 请问各位高手如何将查询结果集中的关键字以红色字体显示?
- 谁有Antechinus C# Editor的注册码??马上给分!!!!!
- 初学者的烦恼,关于serialport timer panel三者。winform编程
- 点击“三角”折叠隐藏在左边
using System.Collections.Generic;
using System.Text;namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int min = int.MaxValue, max = int.MaxValue*-1;
int i = 0;
Console.WriteLine("请输入一个整数并回车确认,退出请直接回车!");
string s = Console.ReadLine();
while (s != "")
{
int n = IsInt(s);
if (min > n)
min = n;
if (max < n)
max = n; i++;
Console.WriteLine("您已经输入" + i.ToString() + "个数,最小为" + min.ToString() + ",最大为" + max.ToString() + ",请输入一个整数并回车确认,退出请直接回车!");
s = Console.ReadLine();
}
} public static int IsInt(string s)
{
if(s==null || s.Length==0)
return 0;
try
{
return int.Parse(s);
}
catch
{
return 0;
}
}
}
}
using System.Collections.Generic;
using System.Text;namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int min = int.MaxValue, max = int.MaxValue*-1;
int i = 0;
Console.WriteLine("请输入一组整数中间用逗号隔开,并回车确认,退出请直接回车!");
string s = Console.ReadLine();
while (s != "")
{
foreach (string st in s.Split(','))
{
int n = IsInt(st);
if (min > n)
min = n;
if (max < n)
max = n;
}
i++;
Console.WriteLine("您已经输入" + i.ToString() + "组数,最小为" + min.ToString() + ",最大为" + max.ToString() + ",请输入一组整数中间用逗号隔开,退出请直接回车!");
s = Console.ReadLine();
}
} public static int IsInt(string s)
{
if(s==null || s.Length==0)
return 0;
try
{
return int.Parse(s);
}
catch
{
return 0;
}
}
}
}
能直接这样写代码么?