zoukankan      html  css  js  c++  java
  • 3月12

    //输入身份证号,截取生日,输出
    // //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();

  • 相关阅读:
    linux安装篇之mongodb安装及服务自启动配置
    Linux下启动mongodb
    java 实现 图片与byte 数组互相转换
    用java imageio调整图片DPI,例如从96调整为300
    StringRedisTemplate操作redis数据
    Docker 更换国内的Hub源
    2、Docker 基础安装和基础使用 一
    Centos 6.x Openssh 升级 7.7p1 版本
    1、Docker 简介
    2. Python环境安装
  • 原文地址:https://www.cnblogs.com/wanlibingfeng/p/5269992.html
Copyright © 2011-2022 走看看