Girilen Sayıya Göre X Çizen Program

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

namespace ConsoleApplication15
{
    class Program
    {
        static void Main(string[] args)
        {
            git:
            Console.Write("Tek sayı giriniz: ");
            int x = Convert.ToInt32(Console.ReadLine());
            if (x%2==0)
            {
                goto git;
            }
            int k = 0, l = x+1;
            for (int i = 1; i <= x; i++)
            {
                k++;
                l--;
                for (int j = 1; j <= x; j++)
                {

                    if (j == i || (i == k && j == l))
                    {
                        Console.Write("* ");
                    }
                    else
                    {
                        Console.Write("  ");
                    }

                }
                Console.WriteLine("");
            }
        }
    }
}
Çift sayı girdiğimizde tekrardan sayı girmemizi isteyecektir.



Yorum Gönder

0 Yorumlar