Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <locale.h>
- using namespace std;
- const int lin=4, col=4;
- typedef float tMat[lin][col];
- void criaMat(tMat &mat)
- {
- for(int i=0; i<lin; i++)
- for(int j=0; j<col; j++)
- {
- cout<<"Informe um número: ";
- cin>>mat[i][j];
- }
- }
- void mostraMat(tMat mat)
- {
- cout<<endl;
- for(int i=0; i<lin; i++)
- {
- for(int j=0; j<col; j++)
- cout<<mat[i][j]<<" ";
- cout<<endl;
- }
- }
- float medPriLin(tMat mat)
- {
- int i=0, soma=0;
- float media;
- for(int j=0; j<col; j++)
- soma+=mat[i][j];
- media=soma/col;
- return media;
- }
- int main()
- {
- setlocale(LC_ALL, "Portuguese");
- tMat mat;
- float result_media;
- criaMat(mat);
- mostraMat(mat);
- result_media=medPriLin(mat);
- cout<<"\nMédia dos elementos da 1ª linha: "<<result_media;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement