Last active
August 23, 2019 03:34
-
-
Save michelthomas/05b7210fde93e64b5044ead74ffb4e60 to your computer and use it in GitHub Desktop.
C utility functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void readArray(int length, int array[]) { | |
int i; | |
for (i = 0; i < length; i++) { | |
scanf("%d", &array[i]); | |
} | |
} | |
void printArray(int length, int array[]) { | |
int i; | |
for (i = 0; i < length; i++) { | |
printf("%d ", array[i]); | |
} | |
} | |
void readMatrix(int m, int n, int matrix[][n]) { | |
int i, j; | |
for (i = 0; i < m; i++) { | |
for (j = 0; j < n; j++) { | |
scanf("%d", &matrix[i][j]); | |
} | |
} | |
} | |
void printMatrix(int m, int n, int matrix[][n]) { | |
int i, j; | |
for (i = 0; i < m; i++) { | |
for (j = 0; j < n; j++) { | |
printf("%d ", matrix[i][j]); | |
} | |
printf("\n"); | |
} | |
} | |
void copyMatrix(int m, int n, int srcMatrix[][n], int destMatrix[][n]) { | |
int i, j; | |
for (i = 0; i < m; i++) { | |
for (j = 0; j < n; j++) { | |
destMatrix[i][j] = srcMatrix[i][j]; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment