Created
September 27, 2017 11:38
-
-
Save thanhhoa214/c539af2f184ce1fce73db7e326628502 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
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