using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace random
{
class Program
{
static void Main(string[] args)
{
Random r = new Random();
int[] a = new int[10];
Console.WriteLine("随机产生的原数组:");
for(int i=0;i<a.Length;i++)
{
a[i] = r.Next(1, 100);
Console.Write(a[i] + " ");
}
Console.WriteLine();
//升序
Array.Sort(a);
Console.WriteLine("升序后的数组:");
for(int j=0;j<a.Length;j++)
{
Console.Write(a[j] + " ");
}
Console.WriteLine();
//反转(将升序反转过后就是降序)
Array.Reverse(a);
Console.WriteLine("(反转)降序后的数组:");
for (int n = 0; n < a.Length; n++)
{
Console.Write(a[n] + " ");
}
Console.ReadKey();
}
}
}
C # Random class using randomly generated integer of 1 to 10 100 and stored in the array, the Array class implements an array element of the sorting and reverse
Guess you like
Origin blog.csdn.net/HCY008042/article/details/104659108
Recommended
Ranking