Advertisement
roronoa

rectangle de # hashtag vide

Jul 15th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. import java.util.*;
  2. class Solution{
  3.     public static void main(String args[]) {
  4.         Scanner in = new Scanner(System.in);
  5.         int N = in.nextInt();
  6.         char[][] mat = new char[N][N];
  7.         for(int i = 0; i < N; i++)
  8.             for(int j = 0; j < N; j++)
  9.                 mat[i][j] = ' ';
  10.         for(int i = 0; i < N; i++)
  11.         {
  12.             mat[i][0]='#';
  13.             mat[0][i]='#';
  14.             mat[N-1][i]='#';
  15.             mat[i][N-1]='#';
  16.         }
  17.         for(int i = 0; i < N; i++)
  18.         {
  19.             for(int j = 0; j < N; j++)
  20.                 System.out.print(mat[i][j]);
  21.             System.out.println();
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement