Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. package hinh_chu_nhat;
  2. import java.util.Scanner;
  3.  
  4.  
  5. public class Hinh_Chu_Nhat {
  6.  
  7.    
  8.     public static void main(String[] args) {
  9.         Scanner Sc=new Scanner(System.in);
  10.         int a,b;//a dai, b rong
  11.         do
  12.         {
  13.             a=Sc.nextInt();
  14.             b=Sc.nextInt();
  15.             if(a<2||b<2) System.out.print("Nhap lai a va b\n");
  16.         }while(a<2||b<2);
  17.         for(int i=0;i<b;i++)
  18.         {
  19.             for(int j=0;j<a;j++)
  20.             {
  21.                 if(j==0||j==(a-1)||i==0||i==(b-1)) System.out.print("#");
  22.                 else System.out.print(" ");
  23.             }
  24.             System.out.print("\n");
  25.         }
  26.     }
  27.    
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement