diff options
Diffstat (limited to 'sem_2/HLIN202/TP/TP9-10/exopart2.cpp')
| -rw-r--r-- | sem_2/HLIN202/TP/TP9-10/exopart2.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/sem_2/HLIN202/TP/TP9-10/exopart2.cpp b/sem_2/HLIN202/TP/TP9-10/exopart2.cpp new file mode 100644 index 0000000..cec0725 --- /dev/null +++ b/sem_2/HLIN202/TP/TP9-10/exopart2.cpp @@ -0,0 +1,51 @@ +#include <iostream>
+
+float** MatMul ( float ** m1, float ** m2, int m, int n, int p) {
+ float ** ret= new float*[n];
+ for ( int i = 0; i<n;i++){
+ ret[i]=new float[n];
+ }
+ for (int i = 0; i<n;i++){
+ for ( int j=0; j < n; j ++){
+ for ( int k=0; k<m; k ++) {
+ for ( int l=0; l<n;l++){
+ ret[i][j]+= m1[k][l]*m2[l][k];
+ }
+ }
+ }
+ }
+ return ret;
+}
+
+float ** CreerMat ( int m, int n){
+ float **T= new float*[m];
+ for (int i = 0; i < m; i ++) {
+ T[i]= new float[n];
+ }
+ for (int i = 0; i < m; i ++) {
+ for (int j= 0; j <n; j ++) {
+ T[i][j] = 1/(float)(i+j+1);
+ }
+ }
+ return T;
+}
+void afficheMat ( float **Mat, int lignes, int colonnes){
+ for ( int i = 0; i<lignes; i ++) {
+ for (int j = 0; j < colonnes;j++){
+ std::cout<<Mat[i][j]<<" ";
+ }
+ std::cout<<std::endl;
+ }
+ std::cout<<std::endl;
+}
+
+int main () {
+ int m,n;
+ std::cin>>m>>n;
+
+ float **T;
+
+ T=MatMul(CreerMat(m,n),CreerMat(m,n), m,n,n);
+ afficheMat(T, m,n);
+ return 0;
+}
|
