一维数组 冒泡排序

1、数组:具有相同类型的若干变量按有序的形式组织起来的一种形式。这些按序排列的同类数据元素的集合称为数组。int[] 变量名 = new int [n];

如int [] array = new int [5]{1,2,3,4,5};表示int一个叫做array的5个数整型数字,其中5个数字是1,2,3,4,5。般情况下,没有花括号!

2、冒泡排序

格式:

1 int temp;
2             int[] arrSort = new int[7] { 10, 8, 3, 5, 6, 7, 9 };
3             for (int i = 0; i < arrSort.Length; i++)
4             {
5                 for (int j = i + 1; j < arrSort.Length; j++)
6                 {
7                     if (arrSort[j] < arrSort[i])
8                     {
9                         temp = arrSort[j];
10                         arrSort[j] = arrSort[i];
11                         arrSort[i] = temp;
12                     }
13                 }
14             }

完!!

原文地址:https://www.cnblogs.com/wwz-wwz/p/5713115.html