
算法
walleyekneel
这个作者很懒,什么都没留下…
展开
-
现有1~100共一百个自然数,已随机放入一个有98个元素的数组a[98]
int[] arry = new int[98]; Random rd = new Random(); List<int> temp = new List<int>(); //随机产生98个1-100自然数 while (temp.Count<98) ...原创 2011-05-20 21:57:39 · 1250 阅读 · 0 评论 -
不使用第三个变量实现俩个数的交换
//不使用第三个变量实现俩个数的交换 int m = 10; int n = 40; Response.Write("原来的值为:" + m + " " + n); n = m + n;//n的值为50 m = n - m;//m的值为40 n = n - m;//n的值为10 ...原创 2011-02-06 21:13:40 · 117 阅读 · 0 评论 -
自己写的一个方法(字符串数组转换字符串),可能不是很严谨,以后再改改...
/// /// 字符串数组转换为字符串(例如:{“12”,“545”}变成12/545) /// /// 传入的字符串数组 /// 分隔符,字符串类型 /// protected static string strTo(string[] str, string apart) ...原创 2011-02-11 15:00:02 · 88 阅读 · 0 评论 -
浅谈递归算法
先看一下一般的做法 //{1,1,2,3,5,8,^}求第三十个数的值(一般做法) protected static int fun2(int n) { int sum = 0; int b = 1; int a = 1; if (n==1) ...原创 2011-02-21 20:11:06 · 114 阅读 · 0 评论 -
找出数组最小的那个
List<int> arry = new List<int>() {-1,1,2,3,4,5,6,7,8,9}; int min=arry[0];//初始化 for (int i = 0; i < arry.Count; i++) { if (min...原创 2011-06-24 09:55:39 · 145 阅读 · 0 评论 -
产生随机不重复的数
/// /// 从1到33中任意选取不重复的6个随机数 /// /// public List GenerateNumber1() { //用于保存返回的结果 List result = new List(6); Random random = new Random(); int temp...原创 2010-12-07 08:28:07 · 126 阅读 · 0 评论 -
冒泡算法C#
//第一种方法 //从小到大排列 int[] sort ={ 3, 5, 7, 1, 2, 4, 8, 9, 11, 10 }; for (int j = 0; j < sort.Length - 1; j++) { for (int i = 0; i < sort....原创 2011-03-24 10:02:10 · 97 阅读 · 0 评论 -
华智公司一道面试题
//说明:例如: //数字123->变成00000123 //123456789->变成23456789 class Program { static void Main(string[] args) { //用户随便输入一个字符串 string s = Console.ReadLi...原创 2011-04-11 13:43:05 · 209 阅读 · 0 评论