C#编程入门_简单算法_15
来源:互联网 发布:天意网络魔域一条龙 编辑:程序博客网 时间:2024/06/05 22:33
21篇C#博客的配套源码
冒泡排序
冒泡排序就是相邻的两个数字进行比较,我们采用的冒泡排序是从前向后进行排序,如果前面的比后面的就进行交换位置。
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 冒泡排序{ class Program { static void Main(string[] args) { int[] arr = { 0, 1, 2, 23, 4, 15, 26, 779, 118, 109 }; BubbleSort(arr); PrintArr(arr); } //用来排序的 static void BubbleSort(int[] arr) { //比较的趟数 for (int i = 0; i < arr.Length -1; i++) { //每一趟要比较的次数 for (int j = 0; j < arr.Length-1-i; j++) { if (arr[j]> arr[j+1]) { int temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; } } } } static void PrintArr(int[] arr) { for (int i = 0; i < arr.Length; i++) { Console.Write(arr[i]+" "); } Console.WriteLine(); } }}
选择排序
折半查找
阅读全文
0 0
- C#编程入门_简单算法_15
- C#编程入门15_简单算法
- C#之入门总结_反射_15
- C#编程入门_网络编程_21
- C#编程入门21_网络编程
- C#与Matlab混合编程_入门
- C#编程入门_循环_5
- C#编程入门_数组_6
- C#编程入门_方法(函数)_7
- C#编程入门_跳转语句_8
- C#编程入门_杂项_12
- C#编程入门_常用集合_14
- C#编程入门_异常处理_16
- C#编程入门_文件处理IO_17
- C#编程入门_反射_19
- C#编程入门5_循环
- C#编程入门6_数组
- C#编程入门7_方法(函数)
- 菜鸟先飞之jAVA_面向对象特征
- Spring复习笔记
- java中的控制流语句
- C++基础-多态
- 电脑软键盘效果
- C#编程入门_简单算法_15
- ListView异步加载图片出现图片错位的解决方案
- Android 调用系统相机部分源码分析
- 数组常用方法
- Lightoj 1122【计数DP】
- MySQL连接失败:Can't connect to MySQL server on '127.0.0.1'
- NIO
- Redis 事务
- CodeForces 3 D.Least Cost Bracket Sequence(贪心+优先队列)