TOPIC
Presentation 5%, não consigo achar o erro.
lcampesatto0 asked 3 years ago
Já tentei todos os tipos de formatações
using System; using System.Globalization;
namespace Programas_Judge { class URI { static void Main(string[] args) { //string[] linha = Console.ReadLine().Split(' ');
int val = Convert.ToInt32(Console.ReadLine()); while(val != 0) { int com = 0, fim = val, pren = 1; int[,] mat = new int[val,val]; int calc = val / 2, calc2 = val / 2 + 1; if(val % 2 == 0) { while(pren <= calc) { for(int i = com; i < fim; i++) { for(int j = com; j < fim; j++) { mat[i,j] = pren; } } com++; fim--; pren++; } } else { while(pren <= calc2) { for(int i = com; i < fim; i++) { for(int j = com; j < fim; j++) { mat[i,j] = pren; } } com++; fim--; pren++; } } for(int i = 0; i < val; i++) { for(int j = 0; j < val; j++) { if(j < val-1) { Console.Write(String.Format("{0,4:0}", mat[i,j])); } else { Console.WriteLine(String.Format("{0,4:0}", mat[i,j])); } } } Console.Write("\n"); val = Convert.ToInt32(Console.ReadLine()); } } }
}