Popular Post

Posted by : Unknown jueves, 12 de junio de 2014



INGRESAR UNA MATRIS DE 4*4 Y GENERAR UN VECTOR V CON LOS ELEMNETOS DIAGONALES


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

namespace ConsoleApplication8
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] m = new int[4, 4];
int[] diagonal = new int[4];

for (int i = 0; i < 4; i++)
            {
Console.WriteLine("Fila " + (i + 1));
for (int j = 0; j < 4; j++)
                {
Console.WriteLine( + (j + 1));
                    m[i, j] = int.Parse(Console.ReadLine());
}
            }
Console.Clear();
//imprimir matricese
Console.WriteLine("Matriz");
for (int i = 0; i < 4; i++)
            {
for (int j = 0; j < 4; j++)
                {
Console.Write(m[i, j] + " ");
                }
Console.WriteLine(" ");
            }
for (int i = 0; i < 4; i++)
            {
                diagonal[i] = m[i, i];
            }
Console.WriteLine("diagonal");
for (int i = 0; i < 4; i++)
            {
Console.Write(diagonal[i] + " ");
            }
Console.ReadLine();

        }
    }
}

Leave a Reply

Subscribe to Posts | Subscribe to Comments

- Copyright © Programación #5 - Date A Live - Powered by Blogger - Designed by Johanes Djogan -