Advertisement
bomman

Problem 5. Disk

Oct 4th, 2015
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 KB | None | 0 0
  1. using System;
  2.  
  3. class Disk
  4. {
  5.     static void Main()
  6.     {
  7.         decimal n = int.Parse(Console.ReadLine());
  8.         decimal r = int.Parse(Console.ReadLine());
  9.  
  10.         char[,] board = new char[(int)n,(int)n];
  11.  
  12.         int x1 = 0;
  13.         int y1 = 0;
  14.         for (int line = 0; line < n; line++)
  15.         {
  16.             for (int row = 0; row < n; row++)
  17.             {
  18.                 double x2 = line - (double)Math.Floor(n / 2);
  19.                 double y2 = row - (double)Math.Floor(n / 2);
  20.                 double pow1 = Math.Pow((x2 - x1), 2);
  21.                 double pow2 = Math.Pow((y2 - y1), 2);
  22.                 if (pow1 + pow2 <=  (int)r * (int)r)
  23.                 {
  24.                     board[line, row] = '*';
  25.                 }
  26.                 else
  27.                 {
  28.                     board[line, row] = '.';
  29.                 }
  30.             }
  31.         }
  32.  
  33.         board[(int)n / 2, (int) n / 2] = '*';
  34.         for (int line = 0; line < n; line++)
  35.         {
  36.             for (int row = 0; row < n; row++)
  37.             {
  38.                 Console.Write(board[line, row]);
  39.             }
  40.             Console.WriteLine();
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement