Advertisement
Qrist

Draw a Circle

Jul 5th, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.36 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Matrix
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double radius;
  10.             double thickness = 0.4;
  11.             ConsoleColor BorderColor = ConsoleColor.Yellow;
  12.             Console.ForegroundColor = BorderColor;
  13.             char symbol = '*';
  14.  
  15.             do
  16.             {
  17.                 Console.Write("Enter radius:::: ");
  18.                 if (!double.TryParse(Console.ReadLine(), out radius) || radius <= 0)
  19.                 {
  20.                     Console.WriteLine("radius have to be positive number");
  21.                 }
  22.             }
  23.             while (radius <= 0);
  24.  
  25.             Console.WriteLine();
  26.             double rIn = radius - thickness, rOut = radius + thickness;
  27.  
  28.             for (double y = radius; y >= -radius; --y)
  29.             {
  30.                 for (double x = -radius; x < rOut; x += 0.5)
  31.                 {
  32.                     double value = x * x + y * y;
  33.                     if (value >= rIn * rIn && value <= rOut * rOut)
  34.                     {
  35.                         Console.Write(symbol);
  36.                     }
  37.                     else
  38.                     {
  39.                         Console.Write(" ");
  40.                     }
  41.                 }
  42.                 Console.WriteLine();
  43.             }
  44.             Console.ReadKey();
  45.         }              
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement