zh_stoqnov

Disk

Oct 30th, 2014
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Disc
  4. {
  5. class Disk
  6. {
  7. public static void Main(string[] args)
  8. {
  9. int n = int.Parse(Console.ReadLine());
  10. int r = int.Parse(Console.ReadLine());
  11. int rowCenter = n / 2,
  12. colCenter = n / 2;
  13. for(int col = 0; col < n; col++)
  14. {
  15. for(int row = 0; row < n; row++)
  16. {
  17. int deltaX = row - rowCenter,
  18. deltaY = col - colCenter;
  19. double distanceCenter = Math.Sqrt(deltaX * deltaX + deltaY * deltaY);
  20. bool inDisc = distanceCenter <= r;
  21. if(inDisc)
  22. {
  23. Console.Write("*");
  24. }
  25. else
  26. {
  27. Console.Write(".");
  28. }
  29. }
  30. Console.WriteLine();
  31. }
  32.  
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment