码迷,mamicode.com
首页 > 其他好文 > 详细

3月12

时间:2016-03-12 21:19:03      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:

//输入身份证号,截取生日,输出
// //string t="12a3@126.com";
// string t="370405198001103810";
// int a, b, c;
// a =int.Parse( t.Substring(6,4));
// b = int.Parse(t.Substring(10,2));
//c = int.Parse(t.Substring(12, 2));
//Console.WriteLine(a+"年"+b+"月"+c+"日");
//Console.ReadLine();

//邮箱格式
//有且只有一个@;
//不能以@开头
//@和.不能在一起
//@后至少有一个.
//不能以.结尾

//方法1:
/* Console.Write("请输入邮箱:");
string mail = Console.ReadLine();
bool a = mail.Contains("@");
if (a == true)
{
int b = mail.IndexOf("@");//第一个@的位置
int c = mail.LastIndexOf("@");//最后一个@的位置
if (b == c)//只能有一个@
{
if (b != 0)//不是以@开头
{
string mail1 = mail.Substring(b);
if (mail1.Contains("."))//如果含有.
{
int d = mail1.IndexOf(".");
if (d != 1) //@和.不在一起
{
if (d != mail1.Length - 1) //.不在最后一位
{
Console.WriteLine("邮箱正确");
}
else
Console.WriteLine("输入有误");
}
else
Console.WriteLine("输入有误");
}
else
Console.WriteLine("输入有误");

}
else
Console.WriteLine("输入有误");

}
else
Console.WriteLine("输入有误");

Console.ReadLine();

}*/
//方法2:
/* Console.WriteLine("输入一个邮箱:");
string s = Console.ReadLine();
if (s.Contains("@"))//包含@字符串
{
int x1 = s.IndexOf("@");
int x2 = s.LastIndexOf("@");
if (x1 == x2 && x1 != 0)//只有一个@并且不是开头
{
int y1 = s.LastIndexOf(".");
if (y1 - x1 > 1)//不在一起且索引号大于2个
{
if (s.LastIndexOf(".") < s.Length - 1)
{
Console.Write("输入正确");
}
else
Console.WriteLine("输入有误");
}
else
Console.WriteLine("输入有误");
}
else
Console.WriteLine("输入有误");
}
else
Console.WriteLine("输入有误");
Console.ReadLine();*/


////随机数类 random
//Random ran = new Random();初始化
//double a = ran.Next(10);0以上,10以下的,不包含10
//随机输入验证码,对照输入,判断是否正确
//错误就清屏,从心开始

String s = "alsfjskldjOWUOIWEURWIOE294892";
for (; ; )
{
Random a = new Random();
string t = "";
for (int i = 1; i <= 4; i++)
{
t += s.Substring(a.Next(s.Length), 1);
}
Console.WriteLine(t);
Console.WriteLine("输入验证码");
string aa = Console.ReadLine();
if (t.ToUpper() == aa.ToUpper())
{
Console.WriteLine("输入验证码正确");
break;
}
else
{
Console.Clear();
Console.WriteLine("输入验证码错误");
}
}
Console.ReadLine();

3月12

标签:

原文地址:http://www.cnblogs.com/wanlibingfeng/p/5269992.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!