diogoAlves

IFF/Introdução à Programação/Slide/Pag 60/Ex 2

Mar 7th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. //IFF - Introdução à Programação
  2. //Slide - Página 60 - Exercício 2
  3. #include<stdio.h>
  4. #include<locale.h>
  5.  
  6. int Soma(int vetor[], int matriz[][5]){
  7.     for(int l=0;l<3;l++){
  8.         for(int c=0;c<5;c++){
  9.             vetor[l]+=matriz[l][c];
  10.         }
  11.     }
  12.     for(int l=0;l<3;l++) printf("Soma dos valores da coluna %d: %d.\n",l+1,vetor[l]);
  13. }
  14. int main(){
  15.     setlocale(LC_ALL,"Portuguese");
  16.     int vetor[3]={0,0,0}, matriz[3][5];
  17.     for(int l=0;l<3;l++){
  18.         for(int c=0;c<5;c++){
  19.             printf("Entre com o valor (%d,%d): ",l+1,c+1);
  20.             scanf(" %d",&matriz[l][c]);
  21.         }
  22.     }
  23.     Soma(vetor, matriz);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment