Problem 3 - Plane

Nov 10th, 2014
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. using System;
2. using System.Collections.Generic;
3. using System.Linq;
4. using System.Text;
6.
7. class Problem3
8. {
9.     static void Main()
10.     {
12.         int width = 3 * n;
13.
14.         Console.WriteLine("{0}*{0}", new String('.', (width - 1) / 2));
15.
16.         int outerDots = (width - 1) / 2 - 1;
17.         int innerDots = 1;
18.
19.         int firstPartCounter = 0;
20.
21.         switch (n)
22.         {
23.             case 5: firstPartCounter = 4; break;
24.             case 7: firstPartCounter = 5;  break;
25.             case 9: firstPartCounter = 6; break;
26.             case 11: firstPartCounter = 7; break;
27.             case 13: firstPartCounter = 8; break;
28.             case 15: firstPartCounter = 9; break;
29.             case 17: firstPartCounter = 10; break;
30.             case 19: firstPartCounter = 11; break;
31.             case 21: firstPartCounter = 12; break;
32.             case 23: firstPartCounter = 13; break;
33.             case 25: firstPartCounter = 14; break;
34.             case 27: firstPartCounter = 15; break;
35.             case 29: firstPartCounter = 16; break;
36.             case 31: firstPartCounter = 17; break;
37.         }
38.
39.         for (int row = 1; row <= firstPartCounter; row++)
40.         {
41.             Console.WriteLine("{0}*{1}*{0}", new String('.', outerDots), new String('.', innerDots));
42.             outerDots--;
43.             innerDots += 2;
44.         }
45.
46.         outerDots = outerDots - 1;
47.         innerDots += 2;
48.
49.         int secondPartCounter = 0;
50.
51.         switch (n)
52.         {
53.             case 5: secondPartCounter = 1; break;
54.             case 7: secondPartCounter = 2; break;
55.             case 9: secondPartCounter = 3; break;
56.             case 11: secondPartCounter = 4; break;
57.             case 13: secondPartCounter = 5; break;
58.             case 15: secondPartCounter = 6; break;
59.             case 17: secondPartCounter = 7; break;
60.             case 19: secondPartCounter = 8; break;
61.             case 21: secondPartCounter = 9; break;
62.             case 23: secondPartCounter = 10; break;
63.             case 25: secondPartCounter = 11; break;
64.             case 27: secondPartCounter = 12; break;
65.             case 29: secondPartCounter = 13; break;
66.             case 31: secondPartCounter = 14; break;
67.         }
68.
69.         for (int row = 1; row <= secondPartCounter; row++)
70.         {
71.             Console.WriteLine("{0}*{1}*{0}", new String('.', outerDots), new String('.', innerDots));
72.             outerDots -= 2;
73.             innerDots += 4;
74.         }
75.
76.         Console.WriteLine("*{0}*{1}*{0}*", new String('.', n - 2), new string('.', n));
77.
78.         int thirdPartCounter = 0;
79.
80.         switch (n)
81.         {
82.             case 5: thirdPartCounter = 1; break;
83.             case 7: thirdPartCounter = 2; break;
84.             case 9: thirdPartCounter = 3; break;
85.             case 11: thirdPartCounter = 4; break;
86.             case 13: thirdPartCounter = 5; break;
87.             case 15: thirdPartCounter = 6; break;
88.             case 17: thirdPartCounter = 7; break;
89.             case 19: thirdPartCounter = 8; break;
90.             case 21: thirdPartCounter = 9; break;
91.             case 23: thirdPartCounter = 10; break;
92.             case 25: thirdPartCounter = 11; break;
93.             case 27: thirdPartCounter = 12; break;
94.             case 29: thirdPartCounter = 13; break;
95.             case 31: thirdPartCounter = 14; break;
96.         }
97.
98.         outerDots = n - 4;
99.         int sideDots = 1;
100.         innerDots = n;
101.
102.         for (int row = 1; row <= thirdPartCounter; row++)
103.         {
104.             Console.WriteLine("*{0}*{1}*{2}*{1}*{0}*", new String('.', outerDots), new String('.', sideDots), new String('.', innerDots));
105.             outerDots -= 2;
106.             sideDots += 2;
107.         }
108.
109.         outerDots = n - 1;
110.         innerDots = n;
111.
112.         for (int row = 1; row <= n; row++)
113.         {
114.             if (row != n)
115.             {
116.                 Console.WriteLine("{0}*{1}*{0}", new String('.', outerDots), new String('.', innerDots));
117.             }
118.             else
119.             {
120.                 Console.WriteLine(new String('*', width));
121.             }
122.             outerDots--;
123.             innerDots += 2;
124.
125.         }
126.
127.
128.     }
129. }