jueves, 27 de marzo de 2014

VECTORES NUMEROS PARES E IMPARES ,SUMA

Nombre:Alexandra Maguana
Ciclo:Sexto Sistemas

 Ingresar en vector1 los numeros pares y vector2 los numeros impares y en el vector3 la suma de los dos.

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

namespace VecSum
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] vec1;
            int[] vec2;
            int[] vec3;
            vec1 = new int[10];
            vec2 = new int[10];
            vec3 = new int[10];
            int y = 0;
            Console.WriteLine("Carga del primer vector.");
            string result="";
            for (int i = 0; i < 20; i++)
            {
                if (i % 2 == 0)
                {
                    vec1[y] = i;
                    result += vec1[y].ToString()+"\t";
                }
                else
                {
                    vec2[y] = i;
                    result += vec2[y].ToString() + "\t";
                    vec3[y] = vec1[y] + vec2[y];
                    result += vec3[y].ToString() + "\n";
                    y++;
                }
            }
            Console.WriteLine(result);
            Console.ReadKey();
        }
    }
}

EJECUCION

No hay comentarios:

Publicar un comentario