Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.mycompany.examen;
- import java.util.Scanner;
- /**
- *
- * @author anton
- */
- public class Ejercicio03 {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.println("Introduzca un nΓΊmero");
- int n = Integer.parseInt(sc.nextLine());
- char[][] matriz = new char[n][n];
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- if (i==j) {
- matriz[i][j] ='A';
- imprimeMatriz(matriz,i,j);
- }else{
- matriz[i][j]='*';
- imprimeMatriz(matriz,i,j);
- }
- }
- System.out.println("");
- }
- }
- public static void imprimeMatriz(char[][] matriz, int i, int j){
- System.out.print(" " + matriz [i][j]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement