Advertisement
CzarnyBarszcz

Untitled

Mar 24th, 2020
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3.  
  4. using namespace std;
  5.  
  6. float **utworz(const int n, const int m)
  7. {
  8. float **M = new float* [n];
  9. for(int i=0;i<n;i++)
  10. {
  11. M[i]= new float[m];
  12. }
  13. for(int i=0;i<n;i++)
  14. {
  15. for(int j=0;j<m;j++)
  16. {
  17. cin>>M[i][j];
  18. }
  19. }
  20. return M;
  21. }
  22. void usun (float **M,const int m)
  23. {
  24. for(int i=0;i<m;i++)
  25. {
  26. delete [] M[i];
  27. }
  28. delete [] M;
  29. }
  30. void wypisz(float **M,const int n, const int m)
  31. {
  32. for(int i=0;i<n;i++)
  33. {
  34. for(int j=0;j<m;j++)
  35. {
  36. cout<<M[i][j];
  37. }
  38. cout<<endl;
  39. }
  40. cout<<endl;
  41. }
  42. void mnozenie(float **&W,float **M1,float **M2,const int n,const int m , const int k ,const int l)
  43. {
  44. W = new float*[m];
  45. float buf;
  46. int a=0;
  47. for(int i=0;i<n;i++)
  48. {
  49. W[i]= new float [l];
  50. }
  51. for(int i=0;i<m;i++)
  52. {
  53. for(int p=0;p<l;p++)
  54. {
  55. buf=0;
  56. for(int j=0;j<m;j++)
  57. {
  58. cout<<M1[j][i];
  59. }
  60.  
  61. }
  62. W[i][a]=buf;
  63. a++;
  64. }
  65. }
  66. int main()
  67. {
  68. int n,m,k,l;
  69. float **M1;
  70. float **M2;
  71. float **W;
  72. // cout<<"PODAJ WYMIARY MACIERZY A : "<<endl;
  73. // cout<<"WIERSZY : ";
  74. // cin>>n;
  75. n=2;
  76. //cout<<"KOLUMN : ";
  77. //cin>>m;
  78. m=1;
  79. M1=utworz(n,m);
  80. // wypisz(M1,n,m);
  81. // cout<<"PODAJ WYMIARY MACIERZY B : "<<endl;
  82. // cout<<"WIERSZY : ";
  83. // cin>>k; */
  84. k=1;
  85. //cout<<"KOLUMN : ";
  86. //cin>>l;
  87. l=2;
  88. M2=utworz(k,l);
  89. //wypisz(M2,k,l);
  90. if(m==k)
  91. {
  92. mnozenie(W,M1,M2,n,m,k,l);
  93. // wypisz(W,n,l);
  94. }
  95. usun(W,n);
  96. usun(M1,m);
  97. usun(M2,l);
  98. getch();
  99. return 0;
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement