Advertisement
AlexJC

Rectangle with Stars

Aug 27th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Rectangle_with_Stars
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int num = int.Parse(Console.ReadLine());
  14.  
  15. var rows = (Math.Ceiling(num / 2.0) - 1);
  16. var ands = new string('%', num * 2);
  17. var space = new string(' ', num * 2 - 2);
  18. var spaceMiddle = new string(' ', (num * 2 - 4) / 2);
  19.  
  20. Console.WriteLine(ands);
  21. for (int i = 0; i < rows; i++)
  22. {
  23. Console.Write("%");
  24. Console.Write(space);
  25. Console.WriteLine("%");
  26. }
  27. Console.Write("%");
  28. Console.Write(spaceMiddle);
  29. Console.Write("**");
  30. Console.Write(spaceMiddle);
  31. Console.WriteLine("%");
  32. for (int i = 0; i < rows; i++)
  33. {
  34. Console.Write("%");
  35. Console.Write(space);
  36. Console.WriteLine("%");
  37. }
  38. Console.WriteLine(ands);
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement