package tst;
import java.util.Scanner;
public class tst {
/**
* @param args
*/
private static int cnt = 0;
private final static String key = new String("aabb");
public static void main(String[] args) {
// TODO Auto-generated method stub
while ( true ) {
Scanner sc = new Scanner(System.in); //java的输入函数
String str = sc.nextLine();
System.out.println("str :" + str); //java的 print()没有换行符 ,println() 自动换行
if ( str.equals( key ) ) {
System.out.println("You are login in");
Scanner scInt = new Scanner(System.in); //也可以直接用sc.nextLine()即可
int getVal = scInt.nextInt();
System.out.println("getVal : " +getVal);
Run( getVal ); //函数调用,刚学会不久
break; //跳出 循环
} else { // 输错了
cnt = cnt + 1;
System.out.println("Please try again!");
if ( cnt >= 3 ) {
System.out.println("You have been input three times wrong keyword");
break;
}
continue;
}
}
}
private static final void Run ( int in ) {
System.out.println("Run"); //实现一个矩阵乘法
int get = in;
int outMult;
for ( int i = 1; i < get; i++ ) {
for ( int j = 1; j < get; j++ ) {
outMult = i * j;
System.out.print(outMult + " ");
}
System.out.println(); //打印一个换行符
}
}
import java.util.Scanner;
public class tst {
/**
* @param args
*/
private static int cnt = 0;
private final static String key = new String("aabb");
public static void main(String[] args) {
// TODO Auto-generated method stub
while ( true ) {
Scanner sc = new Scanner(System.in); //java的输入函数
String str = sc.nextLine();
System.out.println("str :" + str); //java的 print()没有换行符 ,println() 自动换行
if ( str.equals( key ) ) {
System.out.println("You are login in");
Scanner scInt = new Scanner(System.in); //也可以直接用sc.nextLine()即可
int getVal = scInt.nextInt();
System.out.println("getVal : " +getVal);
Run( getVal ); //函数调用,刚学会不久
break; //跳出 循环
} else { // 输错了
cnt = cnt + 1;
System.out.println("Please try again!");
if ( cnt >= 3 ) {
System.out.println("You have been input three times wrong keyword");
break;
}
continue;
}
}
}
private static final void Run ( int in ) {
System.out.println("Run"); //实现一个矩阵乘法
int get = in;
int outMult;
for ( int i = 1; i < get; i++ ) {
for ( int j = 1; j < get; j++ ) {
outMult = i * j;
System.out.print(outMult + " ");
}
System.out.println(); //打印一个换行符
}
}
}
不想截图了:
运行结果:
aabb
str :aabb
You are login in
5
getVal : 5
Run
1 2 3 4
2 4 6 8
3 6 9 12
4 8 12 16