Advertisement
Guest User

main

a guest
Apr 21st, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.59 KB | None | 0 0
  1. // projet.cpp : définit le point d'entrée pour l'application console.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "CMatrice.h"
  6.  
  7.  
  8. int main( int argc, char* argv[])
  9. {
  10.     /*CMatrice<int> test1 = *(new CMatrice<int>(2, 2));
  11.     for (int i = 0; i<2; i++)
  12.         for (int j = 0; j<2; j++)
  13.             test1.MATmodifElem(3 * i + j, i, j);
  14.  
  15.     printf("%d %d\n%d %d\n\n", test1.MATlireElement(0, 0), test1.MATlireElement(0, 1), test1.MATlireElement(1, 0), test1.MATlireElement(1, 1));
  16.     CMatrice<int> test2 = *(new CMatrice<int>(test1));
  17.     printf("%d %d\n%d %d\n\n", test2.MATlireElement(0, 0), test2.MATlireElement(0, 1), test2.MATlireElement(1, 0), test2.MATlireElement(1, 1));
  18.     CMatrice<int> test3 = test1 + test2;
  19.     printf("%d %d\n%d %d\n\n", test3.MATlireElement(0, 0), test3.MATlireElement(0, 1), test3.MATlireElement(1, 0), test3.MATlireElement(1, 1));
  20.     CMatrice<int> test4 = test3 / 10;
  21.     printf("%d %d\n%d %d\n\n", test4.MATlireElement(0, 0), test4.MATlireElement(0, 1), test4.MATlireElement(1, 0), test4.MATlireElement(1, 1));
  22.     CMatrice<int> test5 = *(test2.poMATtransposee());
  23.     printf("%d %d\n%d %d\n\n", test5.MATlireElement(0, 0), test5.MATlireElement(0, 1), test5.MATlireElement(1, 0), test5.MATlireElement(1, 1));
  24.     //CMatrice<int>* test6 = &(*test2**test5);
  25.     CMatrice<int> test6 = test2*test5;
  26.     printf("%d %d\n%d %d\n\n", test6.MATlireElement(0, 0), test6.MATlireElement(0, 1), test6.MATlireElement(1, 0), test6.MATlireElement(1, 1));
  27.  
  28.     CMatrice<long>* test7 = new CMatrice<long>(2, 2);
  29.     test7->MATmodifElem(1, 0, 0);
  30.     test7->MATmodifElem(1, 0, 1);
  31.     test7->MATmodifElem(1999999999, 1, 0);
  32.     test7->MATmodifElem(1999999999, 1, 1);
  33.     test7->MATaffichage();
  34.     CMatrice<double> test8 = *test8.poMATlireFichier("C:/Users/val/Desktop/matrices/32a.txt");
  35.     //printf("%.2f %.2f %.2f\n%.2f %.2f %.2f\n\n", test8.MATlireElement(0, 0), test8.MATlireElement(0, 1), test8.MATlireElement(0, 2), test8.MATlireElement(1, 0), test8.MATlireElement(1, 1), test8.MATlireElement(1, 2));
  36.     test8.MATaffichage();*/
  37.     if (argc == 1) {
  38.         throw new Cexception(EXC_NBPARAMERR, "Nombre de parametres insuffisant");
  39.     }
  40.     else {
  41.         double c = 0;
  42.         /*printf("%s", argv[1]);
  43.         printf("%s", argv[2]);*/
  44.  
  45.         CMatrice<double>** matrices = (new CMatrice<double>*[argc]);
  46.         for (int i = 0; i < argc - 1; i++)
  47.             matrices[i] = (matrices[i]->poMATlireFichier(argv[i + 1]));
  48.         printf("Veuillez saisir la valeur de C : ");
  49.         //scanf("%lf", &c);
  50.         cin >> c;
  51.  
  52.         for (int i = 0; i < argc - 1; i++) {
  53.             printf("\nLe produit de la matrice \n");
  54.             matrices[i]->MATaffichage();
  55.             printf("\nPar le scalaire %.2f\n", c);
  56.             (*matrices[i] * c).MATaffichage();
  57.         }
  58.  
  59.         for (int i = 0; i < argc - 1; i++) {
  60.             printf("\nLa division de la matrice \n");
  61.  
  62.             matrices[i]->MATaffichage();
  63.             printf("\nPar le scalaire %.2f\n", c);
  64.             (*matrices[i] / c).MATaffichage();
  65.         }
  66.        
  67.         CMatrice<double> *somme;
  68.         for (int i = 1; i < argc - 1; i++)
  69.             somme= *matrices[i-1] + *matrices[i];
  70.         printf("\nSomme des matrices \n");
  71.         //matrices[1]->MATaffichage();
  72.         printf("%.2f", somme->MATlireElement(0, 0));
  73.         somme->MATaffichage();
  74.  
  75.         CMatrice<double> sommeAlt = *(new CMatrice<double>(*(matrices[0])));
  76.         for (int i = 2; i < argc - 1; i += 2) {
  77.             sommeAlt = sommeAlt - *matrices[i];
  78.             if (i + 1 < argc)
  79.                 sommeAlt = sommeAlt + *matrices[i + 1];
  80.         }
  81.         printf("\nLa somme alternée de toutes les matrices vaut\n");
  82.         sommeAlt.MATaffichage();
  83.  
  84.         CMatrice<double> produit = *(new CMatrice<double>(*(matrices[0])));
  85.         for (int i = 1; i < argc - 1; i++)
  86.             produit = produit * *matrices[i];
  87.         printf("\nLe produit de toutes les matrices vaut\n");
  88.         produit.MATaffichage();
  89.     }
  90.  
  91.     return 0;
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement