Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _10.RectangleWithStars
- {
- class RectangleWithStars
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int colsCnt = n * 2;
- int rowsCnt;
- if (n % 2 == 0)
- {
- rowsCnt = n + 1;
- }
- else
- {
- rowsCnt = n + 2;
- }
- for (int row = 0; row < rowsCnt; row++)
- {
- for (int col = 0; col < colsCnt; col++)
- {
- if (row == 0 || row == rowsCnt - 1)
- {
- Console.Write("%");
- }
- else if (col == 0 || col == colsCnt - 1)
- {
- Console.Write("%");
- }
- else if (row == rowsCnt / 2 && (col == colsCnt / 2 || col == (colsCnt - 1) / 2))
- {
- Console.Write("*");
- }
- else
- {
- Console.Write(" ");
- }
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement