-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPBMFileContents.cs
100 lines (90 loc) · 2.84 KB
/
PBMFileContents.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using System;
class Program
{
public static void Main(string[] args)
{
int sizeSquare;
int sizeBorder;
int colorSquare;
int colorBorder;
int TotalSize;
Console.Write("Enter the size of the square: ");
sizeSquare = Convert.ToInt32(Console.ReadLine());
while (sizeSquare < 0)
{
Console.WriteLine("Invalid Input");
Console.Write("Enter the size of the square: ");
sizeSquare = Convert.ToInt32(Console.ReadLine());
}
Console.Write("Enter the size of the border: ");
sizeBorder = Convert.ToInt32(Console.ReadLine());
while (sizeBorder < 0)
{
Console.WriteLine("Invalid input!");
Console.Write("Enter the size of the border: ");
sizeBorder = Convert.ToInt32(Console.ReadLine());
}
Console.Write("Enter the color of the square: ");
colorSquare = Convert.ToInt32(Console.ReadLine());
while (colorSquare != 0 && colorSquare != 1)
{
Console.WriteLine("Invalid input!");
Console.Write("Enter the color of the square: ");
colorSquare = Convert.ToInt32(Console.ReadLine());
}
Console.Write("Enter the color of the border: ");
colorBorder = Convert.ToInt32(Console.ReadLine());
while (colorBorder != 0 && colorBorder != 1)
{
Console.WriteLine("Invalid input!");
Console.Write("Enter the color of the border: ");
colorBorder = Convert.ToInt32(Console.ReadLine());
}
TotalSize = sizeSquare + (2 * sizeBorder);
Console.WriteLine("PBM File Contents:");
Console.WriteLine("P1");
Console.WriteLine(TotalSize + " " + TotalSize);
if (sizeBorder != 0)
{
for (int i = 0; i < sizeBorder; i++)
{
for (int x = 0; x < TotalSize; x++)
{
Console.Write("0");
}
Console.Write("\n");
}
}
for (int i = 0; i < sizeSquare; i++)
{
int x = 0;
while (x < sizeBorder)
{
Console.Write(colorBorder);
x++;
}
for (int j = 0; j < sizeSquare; j++)
{
Console.Write(colorSquare);
}
x = 0;
while (x < sizeBorder)
{
Console.Write(colorBorder);
x++;
}
Console.WriteLine(" ");
}
if (sizeBorder != 0)
{
for (int i = 0; i < sizeBorder; i++)
{
for (int x = 0; x < TotalSize; x++)
{
Console.Write("0");
}
Console.Write("\n");
}
}
}
}