/**
Write a program in C# language to perform the following operation:
b. Finding greatest of n numbers
**/
using System;
using System.Linq;
class Greatest
{
public static void Main(String[] args)
{
//get the number of elements
Console.WriteLine("Enter the number of elements");
int n;
n=Convert.ToInt32(Console.ReadLine());
int[] array1 = new int[n];
//accept the elements
for(int i=0; i<n; i++)
{
Console.WriteLine("Enter element no:",i+1);
array1[i]=Convert.ToInt32(Console.ReadLine());
}
//Greatest
int max=array1.Max();
Console.WriteLine("The max is ", max);
Console.Read();
}
}
程序没有输出变量的值,我不知道为什么??
样本输出为
Enter the number of elements
3
Enter element no:
2
Enter element no:
3
Enter element no:
2
The max is
注意变量没有输出。
谢谢