stefan1919

circle console

Jul 30th, 2015
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6.  
  7. namespace novo2
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             int r = int.Parse(Console.ReadLine());
  15.             int center = n / 2;
  16.             for (int i = 0; i < n; i++)
  17.             {
  18.                 for (int j = 0; j < n; j++)
  19.                 {
  20.                     int x = center - i;
  21.                     int y = center - j;
  22.                     double distance = Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2));
  23.                     if (distance <= r)
  24.                     {
  25.                         Console.Write("*");
  26.                     }
  27.                     else
  28.                     {
  29.                         Console.Write(".");
  30.                     }
  31.                    
  32.                 }
  33.                 Console.WriteLine();
  34.             }
  35.             }
  36.         }
  37.     }
Advertisement
Add Comment
Please, Sign In to add comment