TOPIC

Presetation erro 5%

gustavos.passos asked 2 years ago

import java.io.IOException; import java.util.Scanner;

public class Main {

public static void main(String[] args) throws IOException 
{
    Scanner in = new Scanner(System.in);
    int a = 1;
    while(a == 1)
    {
        int val = in.nextInt();
        int[][] cVal = new int[val][val]; 

        if(val == 0) break;
        else
        {
            for(int i = 0; i < val; i++)
            {
                for(int j = 0; j < val; j++)
                {
                    cVal[i][j] = 1;
                }
            }

            int pivo = Math.round(val / 2);

            for(int h = 1; h <= pivo; h++)
            {
                for(int i = h; i < val-h; i++)
                {
                    for(int j = h; j < val-h; j++)
                        cVal[i][j] += 1;
                }
            }
        }    

        for(int i = 0; i < val; i++)
        {
            for(int j = 0; j < val; j++)
            {
                if(cVal[i][j] < 10) System.out.printf(" %d  ", cVal[i][j]);
                else System.out.printf(" %d ", cVal[i][j]);
            }
            System.out.println();
        }
    }
}

}

This topic has not been answered yet. Be the first!

Remember not post solutions. Your post may be reviewed by our moderators.