0727数组
一. 一位数组
//int[] array = new int[5]{1,2,3,4,5};
//int[] array = new int[5];
//array[0] = 1;
//array[1] = 2;
//array[2] = 3;
//array[3] = 4;
//array[4] = 5;
////array[5] = 6; 超出索引范围
//int a = array[2];
//string[] ss = new string[3];
//ss[0] = "1";
//ss[1] = "2";
//ss[2] = "3";
//string b = ss[2];
//输入三个名字放入数组
//string[] name = new string[3];
//Console.Write("请输入第一个人名:");
//name[0] = Console.ReadLine();
//Console.Write("请输入第二个人名:");
//name[1] = Console.ReadLine();
//Console.Write("请输入第三个人名:");
//name[2] = Console.ReadLine();
//Console.ReadLine();
//从控制台输入班级人数
//将每个人的年龄放入数组
//求总和
//求平均年龄
//最大值
//Console.Write("请输入班级人数:");
//int n = int.Parse(Console.ReadLine());
//int[] a = new int[n]; int b = 0;
//for (int i = 0; i < n ;i++ )
//{
// Console.Write("请输入第{0}个人的年龄:",i+1);
// a[i] = int.Parse(Console.ReadLine());
// b += a[i];
//}
//Console.Write("所有人的年龄输入完毕!");
//Console.ReadLine();
//Console.WriteLine();
//Console.WriteLine("年龄总和为:{0}。",b);
//Console.WriteLine(b/n);
//int c = 0;
//for (int i = 0; i < n;i++ )
//{
// if(c<a[i])
// {
// c = a[1];
// }
//}
//Console.WriteLine("最大年龄为:{0}",c);
//冒泡排序
//for (int i = 0; i < n; i++)
//{
// for (int j = i; j < n-1; j++)
// {
// if (age[i] < age[j+1])
// {
// int zhong = age[i];
// age[i] = age[j+1];
// age[j+1] = zhong;
// }
// }
//}
//for (int i = 0; i < n; i++)
//{
// Console.WriteLine(age[i]);
//}
// Console.ReadLine();
//输入班级人数
//输入每个人的分数
//求总分 平均分 两个最高分 两个最低分
//Console.Write("请输入班级人数:");
//int n = int.Parse(Console.ReadLine());
//double [] a = new double[n];
//double b = 0;
//for (int i = 0; i < n; i++)
//{
// Console.Write("请输入第{0}个人的分数:", i + 1);
// a[i] = double.Parse(Console.ReadLine());
// b += a[i];
//}
//Console.Write("所有人的分数输入完毕!");
//Console.WriteLine();
//Console.WriteLine("分数总和为:{0}。", b);
//Console.WriteLine("平均分为::{0}", b / n);
//for (int i = 0; i < n; i++)
//{
// for (int j = i; j < n-1 ; j++)
// {
// if (a[i] < a[j + 1])
// {
// double zhong = a[i];
// a[i] = a[j+1];
// a[j+1] = zhong;
// }
// }
//}
//Console.WriteLine("两个最高分为:{0}、{1};两个最低分为:{2}、{3}。", a[0], a[1], a[n - 2], a[n-1]);
//Console.ReadLine();
//验证码
//string ss = "ABCDEFGHIJKLMNOPQRRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
//Random ran = new Random();
//int a = ran.Next(0, 62);
//string a1 = ss.Substring(a, 1);
//int b = ran.Next(0, 62);
//string b1 = ss.Substring(b, 1);
//int c = ran.Next(0, 62);
//string c1 = ss.Substring(c, 1);
//int d = ran.Next(0, 62);
//string d1 = ss.Substring(d, 1);
//string f = a1 + b1 + c1 + d1;
// string[] aa=new string []{f};
// Console.WriteLine(aa[0]);
// string f1 = aa[0].ToLower();
// Console.Write("请输入验证码:");
// string e = Console.ReadLine();
// string e1 = e.ToLower();
// if (f1 == e1)
// {
// Console.WriteLine("您输入的验证码正确。");
// }
// else
// {
// Console.WriteLine("您输入的验证码错误。");
// }
//string[] zimu = new string[] { "A", "B", "C", "D", "E", "F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9" };
//Random ran = new Random();
//int yanzheng1 = ran.Next(0,62);
//int yanzheng2 = ran.Next(0, 62);
//int yanzheng3 = ran.Next(0, 62);
//int yanzheng4 = ran.Next(0, 62);
//string yanzhengma = zimu[yanzheng1] + zimu[yanzheng2] + zimu[yanzheng3] + zimu[yanzheng4];
//Console.WriteLine(yanzhengma);
//Console.Write("请输入验证码:");
//string yanzhengmahehe = Console.ReadLine();
//string yanzhenmgmaheihei = yanzhengmahehe.ToLower();
//string yanzhengmahaha = yanzhengma.ToLower();
//if (yanzhenmgmaheihei == yanzhengmahaha)
//{
// Console.WriteLine("您输入的验证码正确!");
//}
//else
//{
// Console.WriteLine("您输入的验证码错误!");
//}
// Console.ReadLine();
//随机100以内的10个不重复的数,放进数组
//int[] array = new int[10];
//Random ran = new Random();
//for (int i = 0; i < 10; i++)
//{
// bool b = true;
// int a = ran.Next(100);
// for (int j = 0; j < i; j++)
// {
// if (a == array[j])
// {
// b = false;
// i--;
// j = 1000;
// }
// }
// if (b == true)
// {
// array[i] = a;
// }
//}
//for (int i = 0; i < 10; i++)
//{
// Console.Write(array[i] + "\t");
//}
//Console.WriteLine();
////由小到大排序
//for (int i = 0; i < 10; i++)
//{
// for (int j = i; j < 9; j++)
// {
// if (array[i] > array[j + 1])
// {
// int zhong = array[i];
// array[i] = array[j + 1];
// array[j + 1] = zhong;
// }
// }
//}
//for (int i = 0; i < 10; i++)
//{
// Console.Write(array[i] + "\t");
//}
//Console.ReadLine();
//滚动显示
//for (int i = 0; i < 50; i++)
//{
// Console.Clear();//清屏
// int a = ran.Next(10);
// Console.WriteLine(array[a]);
// //暂停100毫秒,0.1秒
// System.Threading.Thread.Sleep(100);
//}
//Console.ReadLine();
//抽奖活动,输入手机号码个数
//将每个手机号码输入数组
//0.1秒滚动显示,5秒结束
//Console.Write("请输入手机号码的个数:");
//int n = int.Parse(Console.ReadLine());
//string[] shouji = new string[n];
//for (int i = 0; i < n; i++)
//{
// Console.Write("请输入第{0}一个手机号码:", i + 1);
// shouji[i] = Console.ReadLine();
//}
//Console.WriteLine("所有手机号码输入完毕!请按回车键进行抽奖活动!");
//Console.ReadLine();
//Random ran = new Random();
//for (int i = 0; i < 50; i++)
//{
// Console.Clear();
// int a = ran.Next(n);
// Console.WriteLine("中奖号码:" + shouji[a]);
// System.Threading.Thread.Sleep(100);
//}
////不管什么都输出自己手机号
//Console.Clear();
//Console.WriteLine("中奖号码:18369907189");
//Console.ReadLine();