Hjälp uppskattas.^^
Här är vad jag har fått ihop:
Ett stycke C#-kod:
namespace VariableArraySort2
{
using System;
public class Class1
{
public static int Main(string[] args)
{
//First read in the numbers of doubles
//the user intends to enter
Console.Write("Enter the numbers of values to sort:");
string sNumElements = Console.ReadLine();
int numElements = Convert.ToInt32(sNumElements);
Console.WriteLine();
//now declare an array of that size
double[] dArray = new double[numElements];
//accumulate the values into an array
for (int i = 0; i < numElements; i++)
{
//prompt the user for another double
Console.Write("enter double #" + (i + 1) + ": ");
string sVal = Console.ReadLine();
double dValue = Convert.ToDouble(sVal);
//add this to the Array
dArray[i] = dValue;
}
//accumulate 'numElements' values from
//the array in the variable dSum
Console.WriteLine();
foreach (int sVal in dArray)
{
Console.WriteLine(sVal);
}
Console.WriteLine("
Sort");
Array.Sort(dArray);
Console.WriteLine();
foreach (int sVal in dArray)
{
Console.WriteLine(sVal);
}
//now sort the array
//output the results inan attractive format
//wait for the user to acknowledge the results
Console.WriteLine("press enter to terminate....");
Console.Read();
return 0;
}
}
}