You are on page 1of 3

1: #include <iostream>

2: #include <fstream>
3: using namespace std;
4: //Nasif Neaz & Deirdre Kimberley
5:
6: const int MAX_ROWS = 200;
7: const int MAX_COLS = 79;
8:
9: void reassembleImage(const string fileName)
10: {
11: ifstream inputFile(fileName);
12:
13: if (!inputFile)
14: {
15: cout << "Failed to open the input file." << endl;
16: return;
17: }
18:
19: int height;
20: inputFile >> height;
21:
22: char image[MAX_ROWS][MAX_COLS];
23:
24: for (int i = 0; i < MAX_ROWS; ++i)
25: {
26: for (int j = 0; j < MAX_COLS; ++j)
27: {
28: image[i][j] = ' ';
29: }
30: }
31:
32: int row, col;
33: char character;
34: while (inputFile >> row >> col >> character)
35: {
36: image[row][col] = character;
37: }
38:
39: for (int i = 0; i < height; ++i) {
40: for (int j = 0; j < MAX_COLS; ++j)
41: {
42: cout << image[i][j];
43: }
44: cout << endl;
45: }
46: }
47:
48: int main()
49: {
50: string fileName;
51: cout << "Enter the name of the input file: ";
52: cin >> fileName;
53:
54: reassembleImage(fileName);
55:
56: return 0;
57: }
58:
59: /* Sample Output 1 (Homer Simpson):
60: Enter the name of the input file: homer_mapped.txt
61: __
62: _ ,___,-'",-=-.
63: __,-- _ _,-'_)_ (""`'-._\ `.
64: _,' __ |,' ,-' __) ,- /. |
65: ,'_,--' | -' _)/ `\
66: ,',' ,' ,-'_,` :
67: ,' ,-' ,(,-( :
68: ,' ,-' , _ ;
69: / ,-._/`---' /
70: / (____)(----. ) ,'
71: / ( `.__, /\ /,
72: : ;-.___ /__\/|
73: | ,' `--. -,\ |
74: : / \ .__/
75: \ (__ \ |_
76: \ ,`-, * / _|,\
77: \ ,' `-. ,'_,-' \
78: (_\,-' ,'\")--,'-' __\
79: \ / // ,'| ,--' `-.
80: `-. `-/ \' | _,' `.
81: `-._ / `--'/ \
82: -hrr- ,' | \
83: / | \
84: ,-' | /
85: / | -'
86:
87:
88: --------------------------------
89: Process exited after 7.894 seconds with return value 0
90: Press any key to continue . . .
91:
92: Sample Output 2 (Mickey Mouse):
93: Enter the name of the input file: mickey_mapped.txt
94: _____
95: .d88888888bo.
96: .d8888888888888b.
97: 8888888888888888b
98: 888888888888888888
99: 888888888888888888
100: Y8888888888888888
101: ,od888888888888888888P
102: .'`Y8P'```'Y8888888888P'
103: .'_ ` _ 'Y88888888b
104: / _` _ ` Y88888888b ____
105: _ | / \ / \ 8888888888.d888888b.
106: d8b | | /| | /| 8888888888d8888888888b
107: 8888_\ \_|/ \_|/ d888888888888888888888b
108: .Y8P `'-. d88888888888888888888888
109: / ` ` `Y8888888888888888
110: | __ 888888888888888P
111: \ / ` dPY8888888888P'
112: '._ .' .' `Y888888P`
113: `"'-.,__ ___.-' .-'
114: jgs `-._```` __..--'`
115:
116:
117: --------------------------------
118: Process exited after 6.4 seconds with return value 0
119: Press any key to continue . . .
120: */
121:

You might also like