密码匹配问题

package Day46;
/*密码要求:
	1.长度超过8位
	2.包括大小写字母.数字.其它符号,以上四种至少三种
	3.不能有相同长度超2的子串重复	 
	       说明:长度超过2的子串*/
//问题分析:第2问,主要是对类型的判别,使用思想转换的思想,转成每种类型对应一个数字,最后看数字加和情况进行分类
//   第三问,对于子串重复问题,先找子串,然后依次判断后边出现子串的情况,只要出现重复出现此则停止。也用了标志的想法。
import java.util.*;
public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
Scanner sc =new Scanner(System.in);
String str;

while(sc.hasNext())
{
    str=sc.nextLine();
     System.out.println( fun(str)); 
	}
	}
	public static String fun(String str)
	{
	    char[] ch;
	    ch=str.toCharArray();
	    if(ch.length<=8)
	  //  System.out.println("NG");
	    	return "NG";
	    int a=0;
	    int b=0;
	    int c=0;
	    int d=0;
	    for(int i=0;i'0'&&ch[i]<'9')
	    	{
	    		a=1;
	    	}
	    	if(ch[i]>'a'&&ch[i]<'z')
	    	{
	    		b=1;
	    	}
	    	if(ch[i]>'A'&&ch[i]<'Z')
	    	{
	    		c=1;
	    	}else
	    		d=1;
	    }
	    if((a+b+c+d)<3)
	    {
	  //  System.out.println("NG");
	    	return "NG";
	    }
	    //第三个条件判断
	    String substring;
	    Vector vv =new Vector(0);
	    for(int i=0;i0)
	    	{
	    		t=1;
	    	}
	    }
		if(t>0)
		{
		//System.out.println("NG");
			return "NG";
		}
	    return "OK";

	}

	
	}


你可能感兴趣的:(每日小结)