Untitled
unknown
plain_text
a year ago
861 B
10
Indexable
import java.util.Scanner; public class PolaXO { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); // Input jumlah baris dan kolom System.out.print("Input jumlah baris : "); int baris = scanner.nextInt(); System.out.print("Input jumlah kolom : "); int kolom = scanner.nextInt(); System.out.println("===================================="); // Nested loop untuk mencetak pola for (int i = 0; i < baris; i++) { for (int j = 0; j < kolom; j++) { if ((i + j) % 2 == 0) { System.out.print("X "); } else { System.out.print("O "); } } System.out.println(); } scanner.close(); } }
Editor is loading...
Leave a Comment