java冒泡排序从⼩到⼤随机数_10个随机数排序(冒泡排序)using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;java生成随机数的方法
using System.Collections;
namespace _1到100内随机⼗个数排序
{
class Program
{
static void Main(string[] args)
{
CreatRandArray();
Console.WriteLine(" ");
CreatSortArray();
Console.Write("递增数列:" + " ");
foreach (int item in Array)
{
if (item / 10 < 1)
{ Console.Write('0' + item.ToString() + " "); }
else
{ Console.Write(item + " "); }
}
Console.ReadKey();
}
static int num;
static int max;
static int[] Array = new int[10];
private static void CreatRandArray()
{
Random rd = new Random();
for (int i = 0; i <= 9; i++)
{
num = rd.Next(1, 100);
Array[i] = num;
}
Console.Write("随机数列:" + " ");
foreach (int item in Array)
{
if (item / 10 < 1)
{ Console.Write('0' + item.ToString() + " "); } else
{ Console.Write(item + " "); }
}
}
private static void CreatSortArray()
{
int temp;
for (int i = 0; i < Array.Length - 1; i++)
{
for (int j = i + 1; j < Array.Length; j++)
{
if (Array[i] > Array[j])
{
temp = Array[j];
Array[j] = Array[i];
Array[i] = temp;
}
}
}
}
}
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。