Cuadro mágico código
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{Llenarcodigos();
}
private void Llenarcodigos()
{
#region[codigoc]
#endregion
}
protected void aceptar_Click(object sender, EventArgs e)
{lblrespuesta.Text = "";
if (TextBox1.Text.Trim() != "")
{
int numero;
try
{
if (TextBox1.Text.Trim() != "1")
{int cuantas = Math.DivRem(Convert.ToInt32(TextBox1.Text), 2, out numero);
if (numero > 0)
{llenarCuadroMagico();
}
else
{
lblrespuesta.Text = "No es un numero inpar";
}
}else
{
lblrespuesta.Text = "debe ser mayor a 1";
}
}
catch
{
lblrespuesta.Text ="debe ser un número";
}
}
}
private void llenarCuadroMagico()
{
int n = Convert.ToInt32(TextBox1.Text.Trim());
int contador = 1;
int i= n / 2 + 1;
int j = n / 2;
int[,] array = new int[n, n];
for (int q = 1; q n - 1)
{
i = i - n;
}if (j > n - 1)
{
j = j - n;
}
}
else
{
i++;
j--;
if...
Regístrate para leer el documento completo.