From fe3029e8d0c3270274d2c2f3b919d1bf8972012b Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Wed, 3 Apr 2019 11:44:45 -0500 Subject: LOGIC CURRENTLY BROKE --- ee1301/wk5/hw5_directory/strap012_HW5C.cpp | 82 +++++++++++++++++++++++------- 1 file changed, 64 insertions(+), 18 deletions(-) (limited to 'ee1301/wk5') diff --git a/ee1301/wk5/hw5_directory/strap012_HW5C.cpp b/ee1301/wk5/hw5_directory/strap012_HW5C.cpp index 701973a..716c413 100644 --- a/ee1301/wk5/hw5_directory/strap012_HW5C.cpp +++ b/ee1301/wk5/hw5_directory/strap012_HW5C.cpp @@ -6,28 +6,27 @@ using namespace std; ifstream fin; #define SIZE 100 -int maxRow = 0, maxColumn = 0; +int maxRow = -1, maxColumn = 0; void getInput(int input[SIZE][SIZE]); void makeNewArray(int oldArray[SIZE][SIZE], int newArray[SIZE][SIZE]); -void pixelAverage(int array[SIZE][SIZE]); +void pixelAverage(int inArray[SIZE][SIZE], int outArray[SIZE][SIZE]); void printArray(int array[SIZE][SIZE]); int main() { fin.open("testData.txt"); - int column = 0, row = 0; - int inputArray[SIZE][SIZE] = {0}; + int inputArray[SIZE][SIZE] = {0}, + outputArray[SIZE][SIZE] = {0}; getInput(inputArray); - int outputArray[SIZE][SIZE] = {0}; makeNewArray(inputArray, outputArray); - pixelAverage(outputArray); + pixelAverage(inputArray, outputArray); printArray(outputArray); } void getInput(int input[SIZE][SIZE]) { string test, temp1; int temp2=0; //I would mainly like to thank some random person on StackOverflow for solving my problem - while (getline(fin,test)) { - temp2 = 0; + while (getline(cin,test)) { + temp2 = -2; istringstream ss(test); while(getline(ss,temp1,' ')) { temp2++; @@ -43,28 +42,75 @@ void getInput(int input[SIZE][SIZE]) { void makeNewArray(int oldArray[SIZE][SIZE], int newArray[SIZE][SIZE]) { for (int i = 0; i < SIZE-1; i++) { - for (int j = 2; j < SIZE-1; j++) { + for (int j = 0; j < SIZE-1; j++) { newArray[i][j] = oldArray[i-1][j-1]; } } } -void pixelAverage(int array[SIZE][SIZE]) { - for (int i = 0; i < maxRow; i++) { - for (int j = 0; j < maxColumn; j++) { - +void pixelAverage(int inArray[SIZE][SIZE], int outArray[SIZE][SIZE]) { + int sum = 0, n = 0, average, timesRan=0; //n is the number of surrounding pixels + for (int i = -1; i < maxRow-1; i++) { + for (int j = -1; j < maxColumn-1; j++) { + sum=0; n=0; + if ( !((i-1)<1) ) { + cout << "LEFT)" << inArray[i-1][j] << " "; + sum += inArray[i-1][j]; + n++; + } + if ( (i+1)