- package day2;
- import java.util.Scanner;
- public class PrintSquareBox {
- public static void main(String[] args) {
- int num = 5;
- for (int i = 0; i < num; i++) {
- System.out.print("3 ");
- }
- System.out.println();
- for (int j = 0; j < num - 2; j++) {
- for (int i = 0; i < num; i++) {
- if (i == 0 || i == num - 1) {
- System.out.print("3 ");
- } else {
- System.out.print("1 ");
- }
- }
- System.out.println();
- }
- for (int i = 0; i < num; i++) {
- System.out.print("3 ");
- }
- }
- }
Output:
Wednesday, April 12, 2017
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment