0% found this document useful (0 votes)
48 views3 pages

"Coloca El Numero Entero Positivo:": Tablamultiplicar

The document defines a TablaMultiplicar class with methods to: 1) Get user input for two positive numbers to use as bounds in a for loop. 2) Perform multiplication tables from the minimum to maximum number using nested for loops. 3) Get user input to define the sizes of two matrices and populate them with user input values. 4) Check that the matrices can be multiplied, multiply them using nested for loops, and output the result.

Uploaded by

Betty Garcia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views3 pages

"Coloca El Numero Entero Positivo:": Tablamultiplicar

The document defines a TablaMultiplicar class with methods to: 1) Get user input for two positive numbers to use as bounds in a for loop. 2) Perform multiplication tables from the minimum to maximum number using nested for loops. 3) Get user input to define the sizes of two matrices and populate them with user input values. 4) Check that the matrices can be multiplied, multiply them using nested for loops, and output the result.

Uploaded by

Betty Garcia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

class TablaMultiplicar

{
int z = 0;
int r = 0;
public void datos()
{
Console.Write("coloca el numero entero positivo:");
do
{
z = Convert.ToInt16(Console.ReadLine());
if (z < 0)
{
Console.WriteLine("coloca un nmero tiene que ser positivo, ingrese otro
nmero");
}
}
while (z < 0);
Console.WriteLine("coloca el numero entero positivo:");
do
{
r = Convert.ToInt16(Console.ReadLine());
if (r <= z)
{
Console.WriteLine("el numero tiene que ser positivo y mayor al primer
nmero");
}
}
while (r <= z);
}
public void operacin()
{
int a, b, i, h, k;
for (a = z; a <= r; a++)
{
k = 0;
for (b = 1; b < (a + 1); b++)
{
if (a % b == 0)
{
k++;
}
}
if (k == 2)
{
i = 1;
do
{
h = a * i;
Console.WriteLine("{0} X {1} = {2}", a, i, h);
i++;
}
while (i <= 10);
}
}
}

public void arreglo()


{
Console.WriteLine("[Matriz 1]");
Console.Write("Filas: ");
int f1 = int.Parse(Console.ReadLine());
Console.Write("Columnas: ");
int c1 = int.Parse(Console.ReadLine());
Console.WriteLine(" \n [Matriz 2]");
Console.Write("Filas: ");
int f2 = int.Parse(Console.ReadLine());
Console.Write("Columnas: ");
int c2 = int.Parse(Console.ReadLine());
int[,] Matriz1 = new int[f1 + 1, c1 + 1];
int[,] Matriz2 = new int[f2 + 1, c2 + 1];
int[,] Multiplicacion = new int[f1 + 1, c2 + 1];
if (c1 == f2)
{
Console.WriteLine(" \n Datos [Matriz 1]: ");
for (int i = 1; i <= f1; i++)
{
for (int j = 1; j <= c1; j++)
{
Console.Write("Ingresa Dato (Fila: {0} - Columna: {1}): ", i, j);
Matriz1[i, j] = int.Parse(Console.ReadLine());
}
}
Console.WriteLine("Datos [Matriz 2]: ");
for (int i = 1; i <= f2; i++)
{
for (int j = 1; j <= c2; j++)
{
Console.Write("Ingresa Dato (Fila: {0} - Columna: {1}): ", i, j);
Matriz2[i, j] = int.Parse(Console.ReadLine());
}
}
for (int i = 1; i <= f1; i++)
{
for (int j = 1; j <= c2; j++)
{
Multiplicacion[i, j] = 0;
for (int z = 1; z <= c1; z++)
{
Multiplicacion[i, j] = Matriz1[i, z] * Matriz2[z, j] + Multiplicacion[i, j];
}
}
}
Console.WriteLine("Multiplicacion de 2 Matrices");
for (int i = 1; i <= f1; i++)
{
for (int j = 1; j <= c2; j++)
{
Console.Write("{0} ", Multiplicacion[i, j]);
}
Console.WriteLine();
}
}
else
{

Console.WriteLine("Error: No se puede multiplicar las matrices" + " Columnas:


{0}! = Filas: {1}", c1, f2);
}
}

}
}

static void Main(string[] args)


{
TablaMultiplicar mostrartablas = new TablaMultiplicar();
mostrartablas.datos();
mostrartablas.operacin();
mostrartablas.arreglo();
Console.ReadLine();
}

You might also like