冒泡排序2
2015-08-12 21:51
302 查看
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace 冒泡12 { class Program { static void W (int[] unsorted) { for (int i = 0; i < unsorted.Length; i++) { for (int j = 0; j < unsorted.Length-1; j++) { if (unsorted[i] > unsorted[j]) { int temp = unsorted[i]; unsorted[i] = unsorted[j]; unsorted[j] = temp; } } } } static void Main(string[] args) { Console.WriteLine("请输入第一个数字:"); int a = int.Parse(Console.ReadLine()); Console.WriteLine("请输入第二个数字:"); int b = int.Parse(Console.ReadLine()); Console.WriteLine("请输入第三个数字:"); int c = int.Parse(Console.ReadLine()); Console.WriteLine("请输入第四个数字:"); int d = int.Parse(Console.ReadLine()); Console.WriteLine("请输入第五个数字:"); int e = int.Parse(Console.ReadLine()); int[] x = {a,b, c ,d,e}; W(x); foreach (int item in x) { Console.Write(item); } Console.ReadLine(); } } }
相关文章推荐
- chrome浏览器安装离线的插件--是百度很久才搜索到的办法
- golang 数组切片(二)
- 基于ftp模式搭建的yum服务器
- hdu1002
- Eclipse工程出现红叉
- Cocos2d-x使用Luajit将Lua脚本编译成bytecode,启用加密
- 多线程编程 实战篇 (三)
- leetcode: Maximum Depth of Binary Tree
- jdk版本的特点
- cookie 和 Session
- iOS开发-UIScreenEdgePanGestureRecognizer实战
- MySQL字符集设置及字符转换(latin1转utf8)
- TableView省市区数组字典 属性传值
- Java笔试面试题006
- 堆、栈 的区别
- 荷兰国旗排序
- mongodb官网文档阅读笔记:与写性能相关的几个因素
- hdu 5373 The shortest problem(模拟、数学规律)
- Lua笔记11-迭代器和闭包
- php入门实现留言板