From 99af25eae563f19fb33a984a11db78f8f0af6c01 Mon Sep 17 00:00:00 2001 From: Srikar Date: Tue, 18 Sep 2018 16:20:45 -0700 Subject: [PATCH] Finished the GitWorkshop Problem --- main.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index a8c909d..2057993 100644 --- a/main.cpp +++ b/main.cpp @@ -29,12 +29,20 @@ int main() { height = stoi(line); //TODO set up data structures - // maybe a 2d vector would be useful? + Pixel arrPix[125][125];// maybe a 2d vector would be useful? + int x; + int y; while(getline(in, line)){ //reads a line at a time //TODO read in pixel data - + stringstream stream(line); + + stream >> x; + stream >> y; + stream >> arrPix[x][y].r; + stream >> arrPix[x][y].g; + stream >> arrPix[x][y].b; } cout << "Width = " << width << endl; //Print to console @@ -48,7 +56,12 @@ int main() { out << 255 << endl; //TODO writing your pixel data in ppm form - + for(int i = 0; i < 125; i++){ + for(int j = 0; j < 125; j++){ + out << arrPix[i][j].r << " " << arrPix[i][j].g << " " << arrPix[i][j].b << "\t"; + } + out << endl; + } out.close(); } in.close();