我都怀疑测开卷子是不是输入用例有问题(比如最后一行字符没打回车)
有大佬帮忙看一下吗
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(sc.hasNext()) { String str = sc.nextLine(); int numtag = 0; int smalltag = 0; int bigtag = 0; int othertag = 0; if (str.length() < 8) { System.out.println("Irregular password"); } else { for (int i = 0; i < str.length(); i++) { if (str.charAt(i) >= '0' && str.charAt(i) <= '9') { numtag++; } else if (str.charAt(i) >= 'a' && str.charAt(i) <= 'z') { smalltag++; } else if (str.charAt(i) >= 'A' && str.charAt(i) <= 'Z') { bigtag++; } else { othertag++; } } if (numtag != 0 && smalltag != 0 && bigtag != 0 && othertag != 0) { System.out.println("OK"); } else { System.out.println("Irregular password"); } } } } }
全部评论
(2) 回帖