0% found this document useful (0 votes)
35 views

Using Using Using Using Using Namespace: Tablamultiplicar

This C# program defines a class called TablaMultiplicar that contains methods to: 1) Get integer input from the user for numbers z and r. 2) Print the multiplication table from z to r by iterating from z to r, and for each number printing the results of multiplying it from 1 to 10. 3) The main method instantiates the TablaMultiplicar class and calls its methods.

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)
35 views

Using Using Using Using Using Namespace: Tablamultiplicar

This C# program defines a class called TablaMultiplicar that contains methods to: 1) Get integer input from the user for numbers z and r. 2) Print the multiplication table from z to r by iterating from z to r, and for each number printing the results of multiplying it from 1 to 10. 3) The main method instantiates the TablaMultiplicar class and calls its methods.

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

using

using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Threading.Tasks;

namespace ConsoleApplication1
{
class TablaMultiplicar
{
int z = 0;
int r = 0;
public void datos()
{

nmero");

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
}
}
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.ReadLine();

static void Main(string[] args)


{
TablaMultiplicar mostrartablas = new TablaMultiplicar();
mostrartablas.datos();
mostrartablas.operacin();
mostrartablas.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 ) ;
}

You might also like