fbinnzhivko

03.01 Disk

Apr 15th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1. using System;
  2. class Disk
  3. {
  4.     static void Main()
  5.     {
  6.         int size = int.Parse(Console.ReadLine());
  7.         int radius = int.Parse(Console.ReadLine());
  8.  
  9.         for (int row = 0; row < size; row++)
  10.         {
  11.             for (int col = 0; col < size; col++)
  12.             {
  13.                 Console.Write("{0}", GetPoint(row, col, radius, size) ? '*' : '.');
  14.             }
  15.             Console.WriteLine();
  16.         }
  17.     }
  18.  
  19.     private static bool GetPoint(int row, int col, int radius, int size)
  20.     {
  21.         int pythagorean = (int)(Math.Pow(row - size / 2, 2) + Math.Pow(col - size / 2, 2));
  22.  
  23.         return pythagorean <= (int)Math.Pow(radius, 2) ? true : false;
  24.     }
  25. }
Add Comment
Please, Sign In to add comment