Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- using namespace std;
- float **utworz(const int n, const int m)
- {
- float **M = new float* [n];
- for(int i=0;i<n;i++)
- {
- M[i]= new float[m];
- }
- for(int i=0;i<n;i++)
- {
- for(int j=0;j<m;j++)
- {
- cin>>M[i][j];
- }
- }
- return M;
- }
- void usun (float **M,const int m)
- {
- for(int i=0;i<m;i++)
- {
- delete [] M[i];
- }
- delete [] M;
- }
- void wypisz(float **M,const int n, const int m)
- {
- for(int i=0;i<n;i++)
- {
- for(int j=0;j<m;j++)
- {
- cout<<M[i][j];
- }
- cout<<endl;
- }
- cout<<endl;
- }
- void mnozenie(float **&W,float **M1,float **M2,const int n,const int m , const int k ,const int l)
- {
- W = new float*[m];
- float buf;
- int a=0;
- for(int i=0;i<n;i++)
- {
- W[i]= new float [l];
- }
- for(int i=0;i<m;i++)
- {
- for(int p=0;p<l;p++)
- {
- buf=0;
- for(int j=0;j<m;j++)
- {
- cout<<M1[j][i];
- }
- }
- W[i][a]=buf;
- a++;
- }
- }
- int main()
- {
- int n,m,k,l;
- float **M1;
- float **M2;
- float **W;
- // cout<<"PODAJ WYMIARY MACIERZY A : "<<endl;
- // cout<<"WIERSZY : ";
- // cin>>n;
- n=2;
- //cout<<"KOLUMN : ";
- //cin>>m;
- m=1;
- M1=utworz(n,m);
- // wypisz(M1,n,m);
- // cout<<"PODAJ WYMIARY MACIERZY B : "<<endl;
- // cout<<"WIERSZY : ";
- // cin>>k; */
- k=1;
- //cout<<"KOLUMN : ";
- //cin>>l;
- l=2;
- M2=utworz(k,l);
- //wypisz(M2,k,l);
- if(m==k)
- {
- mnozenie(W,M1,M2,n,m,k,l);
- // wypisz(W,n,l);
- }
- usun(W,n);
- usun(M1,m);
- usun(M2,l);
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement