摘要: static void Main(string[] args) { int n = 1; while (n < 6) //在括号内直接限制循环条件 { Console.WriteLine( "打印结果{0},{1}",n,2*n); n = n + 1; //需要在中括号内给出改变方式,否则将进入... 阅读全文
posted @ 2015-04-16 10:12 zhenximeiyitian 阅读(104) 评论(0) 推荐(0) 编辑
摘要: static void Main(string[] args) { ArrayList al = new ArrayList(); Console.Write("请输入人数"); int n = Convert.ToInt32(Console.ReadLine()); for (int i = 0... 阅读全文
posted @ 2015-04-16 10:09 zhenximeiyitian 阅读(154) 评论(0) 推荐(0) 编辑
摘要: static void Main(string[] args) { ArrayList al = new ArrayList();//集合里面所有类型都可以放入 Console.Write("请输入人数:"); int n = Convert.ToInt32(Console.ReadLine());... 阅读全文
posted @ 2015-04-15 16:23 zhenximeiyitian 阅读(208) 评论(0) 推荐(0) 编辑
摘要: while (true) { Random r = new Random();//定义随机数 ArrayList red = new ArrayList();//集合类型可以放入 while (true) { if (red.Count == 6)//红球包含六个数 { break;//选出六个... 阅读全文
posted @ 2015-04-15 16:20 zhenximeiyitian 阅读(223) 评论(0) 推荐(0) 编辑
摘要: class Program { public int[] shuchucanshu(int[] shu,out int a,out int b) //基本格式,定义一个int数组 { for (int i = 0; i < shu.Length ; i++) //冒泡排序 { for (int j ... 阅读全文
posted @ 2015-04-15 16:03 zhenximeiyitian 阅读(173) 评论(0) 推荐(0) 编辑
摘要: public int qiuyang(int cun) { int sum = 0; if (cun==7)//如果是第七个村就剩2只,那么函数结束 { sum = 2; return sum; } sum = (qiuyang(cun + 1) + 1) * 2; //(下一个村数量+1)*2; ... 阅读全文
posted @ 2015-04-15 15:24 zhenximeiyitian 阅读(231) 评论(0) 推荐(0) 编辑
摘要: Random r = new Random(); //随机定义两个人 string[] s1 = new string[] { "剪刀", "石头", "布" }; string[] s2 = new string[] { "剪刀", "石头", "布" }; //随机定义两个人的数组 strin... 阅读全文
posted @ 2015-04-15 15:15 zhenximeiyitian 阅读(278) 评论(0) 推荐(0) 编辑
摘要: 对折纸的例题: double houdu = 0.001; for (int i = 1; 1==1; i++) { houdu = houdu + houdu; Console.WriteLine("第"+i+"次对折后纸的厚度为"+houdu+"米" ); if (houdu >=8848) {... 阅读全文
posted @ 2015-04-15 14:43 zhenximeiyitian 阅读(1011) 评论(0) 推荐(0) 编辑
摘要: int n = 0; //定义初始值为0 for (int a = 0; a=1&&a+b+c==8) //输入条件,至少一个白球,三种球加起来个数为8个 { Console.WriteLine(a+"红球"+b+"白球"+c+"黑球"); n++; //每有一种可能性加一次 } } } } Co... 阅读全文
posted @ 2015-04-15 14:23 zhenximeiyitian 阅读(362) 评论(0) 推荐(0) 编辑
摘要: string email = Console.ReadLine(); if (email.Contains("@") && email.Contains(".com")) { Console.WriteLine("这是一个正确的邮箱地址"); int intex = email.IndexOf("... 阅读全文
posted @ 2015-04-14 23:37 zhenximeiyitian 阅读(279) 评论(0) 推荐(0) 编辑