Created
September 27, 2017 12:09
-
-
Save thanhhoa214/63919a23156b5b26f7e201bf8fef6756 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Hello { | |
public static void main(String[] args) { | |
Scanner sc=new Scanner(System.in); | |
//dài | |
System.out.println("Nhập chiều dài mảng: "); | |
int dai=0; | |
boolean flag; | |
do { | |
flag =sc.hasNextInt(); | |
if (flag) dai=sc.nextInt(); | |
else { | |
System.out.println("Try Again!"); | |
sc.nextLine(); | |
} | |
} while(!flag); | |
//rộng | |
System.out.println("Nhập chiều rộng mảng: "); | |
int rong=0; | |
do { | |
flag =sc.hasNextInt(); | |
if (flag) rong=sc.nextInt(); | |
else { | |
System.out.println("Try Again!"); | |
sc.nextLine(); | |
} | |
} while(!flag); | |
System.out.println(dai+" "+rong); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment