Вы находитесь на странице: 1из 3

using System;

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

namespace sumadedosvectoresconmetodo
{
class Program
{
static void Main(string[] args)
{
int[] vector1 = new int[1000];
int[] vector2 = new int[1000];
int[] vector3 = new int[1000];
int numvec;
verdaderasuma objeto = new verdaderasuma();
Console.WriteLine("cuantos valores deseas que tengan tus vectores: ");
numvec = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(" ");
Console.WriteLine("ingresa valores al vector 1:");
for (int i = 0; i < numvec; i++)
{
Console.Write("ingrese valor [" + i +"]: ");
vector1[i] = Convert.ToInt32(Console.ReadLine());
objeto.Valor1 = vector1;
}
Console.WriteLine(" ");
Console.WriteLine("ingresa valores al vector 2:");
for (int i = 0; i < numvec; i++)
{
Console.Write("ingrese valor [" + i + "]: ");
vector2[i] = Convert.ToInt32(Console.ReadLine());
objeto.Valor2 = vector2;
}
objeto.Tmñ = numvec;
objeto.operar();
Console.WriteLine(" ");
Console.WriteLine("La suma de los vectores es: ");
for (int i = 0; i < numvec; i++)
{
Console.WriteLine("suma posicion [" + i + "]: {0}",
objeto.Resultado[i]);
}
Console.ReadLine();
}
}
}

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

namespace sumadedosvectoresconmetodo
{
public class suma
{
public int[] valor1 = new int[1000];
public int[] valor2 = new int[1000];
public int[] resultado = new int[1000];
private int tmñ;

public int[] Valor1


{
get { return valor1;}
set { valor1 = value;}
}

public int[] Valor2


{
get
{
return valor2;
}

set
{
valor2 = value;
}
}

public int[] Resultado


{
get
{
return resultado;
}

set
{
resultado = value;
}
}

public int Tmñ


{
get
{
return tmñ;
}

set
{
tmñ = value;
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace sumadedosvectoresconmetodo
{
public class verdaderasuma : suma
{
public void operar()
{
for (int i = 0; i < Tmñ; i++)
{
Resultado[i] = Valor1[i] + Valor2[i];
}
}
}
}

Вам также может понравиться