Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- const int m=4, n=4;
- const char sRedText[] = "\033[1;31m";
- const char sBlueText[] = "\033[1;34m";
- const char sDefText[] = "\033[0m";
- //REF sobre as cores:
- // https://bit.ly/3q2kUo0
- void le_matriz(int mat[m][n]);
- void imprime_matriz(int mat[m][n]);
- // Entrada de dados, Matriz 4x4
- // 1 -2 3 -4 305 6 -7 8 -9 0 11 12 13 214 15 0
- int main() {
- int mat[m][n], MI[m][n];
- le_matriz(mat);
- printf("Dados da matriz original: \n");
- imprime_matriz(mat);
- return 0;
- }
- void le_matriz(int mat[m][n]) {
- for(int i=0; i<m; i++)
- for(int j=0; j<n; j++)
- scanf("%d", &mat[i][j]);
- }
- void imprime_matriz(int mat[m][n]) {
- for(int i=0; i<m; i++) {
- for(int j=0; j<n; j++) {
- if(mat[i][j] < 0)
- printf("%s %4d", sRedText, mat[i][j]);
- else if(mat[i][j] > 0)
- printf("%s %4d", sBlueText, mat[i][j]);
- else
- printf("%s %4d", sDefText, mat[i][j]);
- }
- printf("\n");
- }
- }
Add Comment
Please, Sign In to add comment