Usuwanie trzeciego wiersza i kolumny z tabliczki mnozenia w C#

0

Witam

Mam pewien problem... Tak jak w temacie chcę usunąć trzeci wiersz i kolumnę z tabliczki mnozenia, lecz nie wiem jak sie do tego zabrac

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = 10;

            for (int y = 1; y <= N; y++)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                if (y == 1)
                {
                    //Nagłówek
                    Console.Write(" x |");
                    for (int x = 1; x <= N; x++)
                    {
                        Console.Write("{0,4}", x);
                    }
                    Console.WriteLine();

                    Console.Write("---+");
                    for (int x = 1; x <= N; x++)
                    {
                        Console.Write("----", x);
                    }
                    Console.WriteLine();

                }

                Console.Write("{0,3}|", y);

                Console.ForegroundColor = ConsoleColor.White;
                for (int x = 1; x <= N; x++)
                {
                    Console.Write("{0,4}", x * y);
                }

                Console.WriteLine();
            }
            Console.ReadLine();
        }
    }
}
0
 
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = 10;
            int columnToDel = 3;

            for (int y = 1; y <= N; y++)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                if (y == 1)
                {
                    //Nagłówek
                    Console.Write(" x |");
                    for (int x = 1; x <= N; x++)
                    {
                        if (x != columnToDel) Console.Write("{0,4}", x);
                    }
                    Console.WriteLine();

                    Console.Write("---+");
                    for (int x = 1; x <= N; x++)
                    {
                        if (x != columnToDel) Console.Write("----", x);
                    }
                    Console.WriteLine();

                }

                if (y != columnToDel) Console.Write("{0,3}|", y);

                Console.ForegroundColor = ConsoleColor.White;
                for (int x = 1; x <= N; x++)
                {
                    if ((y != columnToDel) && (x != columnToDel)) Console.Write("{0,4}", x * y);
                }

                if (y != columnToDel) Console.WriteLine();
            }
            Console.ReadLine();
        }
    }
}


 

1 użytkowników online, w tym zalogowanych: 0, gości: 1