#include #include ///Useful macros #define CON "CON" ///write to console #define ASC "ASC" ///ascending order #define DESC "DESC" ///descending order void allocate2DArray(float ***pArray, int rows, int cols); void readAllData(const char* fileName, float ***pArray, int *rows, int *cols); void readArrayFromConsole(float **pArray, int rows, int cols); void readArrayFromFile(float **pArray, int rows, int cols); void fillArrayWithRandomValues(float **pArray, int rows, int cols, float start, float end); void fillArrayWithSpecificValue(float **pArray, int rows, int cols, float value); void printArray(const char* destination, float **pArray, int rows, int cols); void printArrayToFile(const char* destination, float **pArray, int rows, int cols); void printArrayToConsole(float **pArray, int rows, int cols); float sumOfAllElements(float **pArray, int rows, int cols); float sumOfGivenRow(float *pArray, int size); float sumOfGivenColumn(float **pArray, int rows, int cols, int givenColumn); float avgOfElements(float **pArray, int rows, int cols); float minimumOfElements(float **pArray, int rows, int cols); float maximumOfElements(float **pArray, int rows, int cols); void sortRow(const char* order, float *pRow, int size); int main() { ///Test 1. /*float **pArray; int rows, cols; ///read the number of rows and cols from file ///allocate memory for the array in main ///read all elements of the array printArrayToConsole(pArray, rows, cols);*/ ///Test 2. /*float **pArray; int rows = 3, cols = 6; allocate2DArray(&pArray, rows, cols); printArrayToConsole(pArray, rows, cols);*/ ///Test 3. /*float **pArray; int rows, cols; readAllData("input.txt", &pArray, &rows, &cols); printArray(CON, pArray, rows, cols);*/ ///Test 4. /*float **pArray; int rows, cols; allocate2DArray(&pArray, rows, cols); fillArrayWithSpecificValue(pArray, rows, cols, 3.14f); printArray("output.txt", pArray, rows, cols);*/ ///Test 5. /*float **pArray; int rows, cols; scanf("%i%i", &rows, &cols); allocate2DArray(&pArray, rows, cols); fillArrayWithRandomValues(pArray, rows, cols, 1.5f, 32.4f); printArray(CON, pArray, rows, cols); printf("SUM of elements: %f\n", sumOfAllElements(pArray, rows, cols)); printf("AVG of elements: %f\n", avgOfElements(pArray, rows, cols)); printf("MIN of elements: %f\n", minimumOfElements(pArray, rows, cols)); printf("MAX of elements: %f\n", maximumOfElements(pArray, rows, cols)); for(int i = 0; i < rows; ++i) { printf("SUM of %i. row is: %f\n", i, sumOfGivenRow(pArray[i], cols)); } printf("Choose a column:"); int givenColumn; scanf("%i", &givenColumn); printf("Sum of column %i is: %f\n", givenColumn, sumOfGivenColumn(pArray, rows, cols, givenColumn)); sortRow(ASC, pArray[0], cols); //What will happen here? printArray(CON, pArray, rows, cols); ///TODO Sort each even row in ASC order and each odd row in DESC order using qsort*/ return 0; }