- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _07数组
- {
- class Program
- {
- static void Main(string[] args)
- {
- //数组类型[] 数组名=new 数组类型[数组长度];
- int[] nums = new int[10];
- //数组的声明方式
- int[] numsTwo = { 1, 2, 3, 4, 5, 6 };
- //string[] str = new string[10];
- ////null ""
- //bool[] bools = new bool[10];
- //Console.ReadKey();
- //nums[0] = 1;
- //nums[1] = 2;
- //nums[2] = 3;
- //nums[3] = 4;
- //nums[4] = 5;
- //nums[5] = 6;
- //nums[6] = 7;
- //nums[7] = 8;
- //nums[8] = 9;
- //nums[9] = 10;
- //nums[10] = 11;
- ////我们通过一个循环给数组赋值,同样,也通过一个循环对数组进行取值
- ////for (int i = 0; i < nums.Length; i++)
- ////{
- //// nums[i] = i;
- ////}
- //for (int i = 0; i < nums.Length; i++)
- //{
- // Console.WriteLine(nums[i]);
- //}
- Console.ReadKey();
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _09冒泡排序
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] nums = { 1, 4, 3, 9, 6, 8, 11 };
- //只能针对数组做一个升序的排列
- //Array.Sort(nums);
- //对数组进行反转
- Array.Reverse(nums);
- //for (int i = 0; i < nums.Length - 1; i++)
- //{
- // for (int j = 0; j < nums.Length - 1-i ; j++)
- // {
- // if (nums[j] > nums[j + 1])
- // {
- // int temp = nums[j];
- // nums[j] = nums[j + 1];
- // nums[j + 1] = temp;
- // }
- // }
- //}
- for (int i = 0; i < nums.Length; i++)
- {
- Console.WriteLine(nums[i]);
- }
- Console.ReadKey();
- }
- }
- }