[code=csharp]using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 返回值
{
class Program
{
static void Main(string[] args)
{
int temp = 0;
int Num = 0;
try
{
Console.WriteLine("请你输入你要比较数值大小的数据个数!");
Num = Convert.ToInt32(Console.ReadLine());
}
catch
{
Console.WriteLine("你输入的数据有误,请重新输入");
Num = Convert.ToInt32(Console.ReadLine());
}
for (int i = 0; i < Num; i++)
{
try
{
Console.WriteLine("请你输如第{0}个数值",i+1);
int number = Convert.ToInt32(Console.ReadLine());
int max = ZMAX(Num, number, temp);
if (i == Num-1)
{
Console.WriteLine("综上所述,最大值为{0}", max);
Console.ReadKey();
break;
}
namespace 返回值
{
class Program
{
static void Main(string[] args)
{
int temp = 0;
int Num = 0;
try
{
Console.WriteLine("请你输入你要比较数值大小的数据个数!");
Num = Convert.ToInt32(Console.ReadLine());
}
catch
{
Console.WriteLine("你输入的数据有误,请重新输入");
Num = Convert.ToInt32(Console.ReadLine());
}
for (int i = 0; i < Num; i++)
{
try
{
Console.WriteLine("请你输如第{0}个数值",i+1);
int number = Convert.ToInt32(Console.ReadLine());
temp= ZMAX(number, temp);
}
catch
{
Console.WriteLine("你输入的数据有误,请重新输入");
i--;
continue;
}
} Console.WriteLine("综上所述,最大值为{0}", temp);
}
public static int ZMAX(int number,int temp)
{
if (number > temp)
{
temp = number;
}
return temp;