i need to know how to do array. but, we insert the input and no user input. when complete the table, we must show the average, maximum score, minimum score and identify which the table has maximum or minimum score using the method.. can help me?
+1
A:
Linq offers extension methods:
arr.Max()
arr.Min()
arr.Average()
Or manually:
int maxIndex=0;
int minIndex=0;
double sum=0;
double min=arr[0];
double max=arr[0];
for(int i=0;i<arr.Length;i++)
{
sum+=arr[i];
if(arr[i]>max)
{
max=arr[i];
maxIndex=i;
}
if(arr[i]<min)
{
min=arr[i];
minIndex=i;
}
}
double average=sum/arr.Length;
Note: The behavior in the presence of NaNs might not be as you want.
CodeInChaos
2010-10-30 13:48:03
i do not understand?
aMeR eJaT
2010-10-30 14:04:37
i'll try, tq so much..
aMeR eJaT
2010-10-30 14:12:42