Skip to content

Instantly share code, notes, and snippets.

@maltzsama
Created March 22, 2017 00:33
Show Gist options
  • Save maltzsama/57e93f753a848562c2393c9909747b03 to your computer and use it in GitHub Desktop.
Save maltzsama/57e93f753a848562c2393c9909747b03 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
int soma(int matriz[3][3]){
int count = 0;
int i, j;
for (i = 0; i < 3; i++){
for (j = 0; j < 3; j++){
count += matriz[i][j];
}
}
printf("%d", count);
return count;
}
int menorsomatorio(int m1[3][3], int m2[3][3], int m3[3][3]){
int soma1 = soma(m1);
int soma2 = soma(m2);
int soma3 = soma(m3);
if(soma1 <= soma2 && soma1 <= soma3)
return soma1;
else if (soma2 <= soma1 && soma2 <= soma3)
return soma2;
else return soma3;
}
int main()
{
int a[3][3] = {1,2,3,4,5,6,7,8,29};
int b[3][3] = {1,2,3,4,5,6,7,8,20};
int c[3][3] = {1,2,3,4,5,6,7,8,11};
int menor = menorsomatorio(a, b, c);
printf("%d", menor);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment