Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- #include<time.h>
- using namespace std;
- using namespace System;
- void crearMatriz(float **&M, int cf, int cc)
- {
- M = new float*[cf];
- for (int i = 0; i <cf; i++)
- {
- M[i] = new float[cc];
- }
- }
- void liberaMatriz(float **M, int cf)
- {
- for (int i = 0; i < cf; i++)
- {
- delete[] M[i];
- }
- delete[] M;
- }
- void cargaMatriz(float **M, int cf, int cc)
- {
- srand(time(NULL));
- for (int i = 0; i < cf; i++)
- {
- for (int j = 0; j < cc; j++)
- {
- M[i][j] = float(rand() % (21));
- }
- }
- }
- void mostrarDatos(float **M, int cf, int cc)
- {
- for (int i = 0; i < cf; i++)
- {
- for (int j = 0; j < cc; j++)
- {
- cout<<M[i][j]<<"\t";
- }
- cout << endl;
- }
- }
- float hallarPromedio(float **M, int cf, int cc)
- {
- float P3 = 0;
- for (int i = 0; i < 30; i++)
- {
- P3 += M[i][2];
- }
- return P3/30;
- }
- void main()
- {
- int cf = 30, cc = 6;
- float **notas;
- crearMatriz(notas, cf, cc);
- cargaMatriz(notas, cf, cc);
- mostrarDatos(notas, cf, cc);
- cout << "Promedio de practica 3: " << hallarPromedio(notas, cf, cc) << endl;
- liberaMatriz(notas, cf);
- system("pause>NULL");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement