aboutsummaryrefslogtreecommitdiff
path: root/8b/9.14.1Knox/9.14.1Knox.cpp
blob: adf6a66fb691ca2c1892c24db0b92e9e839d7612 (plain) (blame)
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
// 9.14.1Knox.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
using namespace std;

void GetInput(int&, int&);
void PrintBox(int, int);

int main()
{
    int width, height;

    GetInput(height, width);
    PrintBox(height, width);
}

void GetInput(int& height, int& width)
{
    cout << "Input the hieght of the box in charcters: ";
    cin >> height;

    cout << "\nInput the width of the box in charcters: ";
    cin >> width;
    cout << "\n\n";

    return;
}

void PrintBox(int height, int width)
{
    for (int y = 1; y <= height; y++)
    {
        for (int x = 1; x <= width; x++)
        {
            char out;
            if (x == 1 && y == 1)
            {
                out = (char) 218;
            }
            else if (x == width && y == 1)
            {
                out = (char) 191;
            }
            else if (y == height && x == 1)
            {
                out = (char) 192;
            }
            else if (y == height && x == width)
            {
                out = (char) 217;
            }
            else 
            {
                if (y == 1 || y == height)
                {
                    out = (char) 196;
                }
                else if (x == 1 || x == width)
                {
                    out = (char) 179;
                }
                else
                {
                    out = ' ';
                }
            }

            cout << out;
        }
        cout << endl;
    }
}