Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // projet.cpp : définit le point d'entrée pour l'application console.
- //
- #include "stdafx.h"
- #include "CMatrice.h"
- int main( int argc, char* argv[])
- {
- /*CMatrice<int> test1 = *(new CMatrice<int>(2, 2));
- for (int i = 0; i<2; i++)
- for (int j = 0; j<2; j++)
- test1.MATmodifElem(3 * i + j, i, j);
- printf("%d %d\n%d %d\n\n", test1.MATlireElement(0, 0), test1.MATlireElement(0, 1), test1.MATlireElement(1, 0), test1.MATlireElement(1, 1));
- CMatrice<int> test2 = *(new CMatrice<int>(test1));
- printf("%d %d\n%d %d\n\n", test2.MATlireElement(0, 0), test2.MATlireElement(0, 1), test2.MATlireElement(1, 0), test2.MATlireElement(1, 1));
- CMatrice<int> test3 = test1 + test2;
- printf("%d %d\n%d %d\n\n", test3.MATlireElement(0, 0), test3.MATlireElement(0, 1), test3.MATlireElement(1, 0), test3.MATlireElement(1, 1));
- CMatrice<int> test4 = test3 / 10;
- printf("%d %d\n%d %d\n\n", test4.MATlireElement(0, 0), test4.MATlireElement(0, 1), test4.MATlireElement(1, 0), test4.MATlireElement(1, 1));
- CMatrice<int> test5 = *(test2.poMATtransposee());
- printf("%d %d\n%d %d\n\n", test5.MATlireElement(0, 0), test5.MATlireElement(0, 1), test5.MATlireElement(1, 0), test5.MATlireElement(1, 1));
- //CMatrice<int>* test6 = &(*test2**test5);
- CMatrice<int> test6 = test2*test5;
- printf("%d %d\n%d %d\n\n", test6.MATlireElement(0, 0), test6.MATlireElement(0, 1), test6.MATlireElement(1, 0), test6.MATlireElement(1, 1));
- CMatrice<long>* test7 = new CMatrice<long>(2, 2);
- test7->MATmodifElem(1, 0, 0);
- test7->MATmodifElem(1, 0, 1);
- test7->MATmodifElem(1999999999, 1, 0);
- test7->MATmodifElem(1999999999, 1, 1);
- test7->MATaffichage();
- CMatrice<double> test8 = *test8.poMATlireFichier("C:/Users/val/Desktop/matrices/32a.txt");
- //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));
- test8.MATaffichage();*/
- if (argc == 1) {
- throw new Cexception(EXC_NBPARAMERR, "Nombre de parametres insuffisant");
- }
- else {
- double c = 0;
- /*printf("%s", argv[1]);
- printf("%s", argv[2]);*/
- CMatrice<double>** matrices = (new CMatrice<double>*[argc]);
- for (int i = 0; i < argc - 1; i++)
- matrices[i] = (matrices[i]->poMATlireFichier(argv[i + 1]));
- printf("Veuillez saisir la valeur de C : ");
- //scanf("%lf", &c);
- cin >> c;
- for (int i = 0; i < argc - 1; i++) {
- printf("\nLe produit de la matrice \n");
- matrices[i]->MATaffichage();
- printf("\nPar le scalaire %.2f\n", c);
- (*matrices[i] * c).MATaffichage();
- }
- for (int i = 0; i < argc - 1; i++) {
- printf("\nLa division de la matrice \n");
- matrices[i]->MATaffichage();
- printf("\nPar le scalaire %.2f\n", c);
- (*matrices[i] / c).MATaffichage();
- }
- CMatrice<double> *somme;
- for (int i = 1; i < argc - 1; i++)
- somme= *matrices[i-1] + *matrices[i];
- printf("\nSomme des matrices \n");
- //matrices[1]->MATaffichage();
- printf("%.2f", somme->MATlireElement(0, 0));
- somme->MATaffichage();
- CMatrice<double> sommeAlt = *(new CMatrice<double>(*(matrices[0])));
- for (int i = 2; i < argc - 1; i += 2) {
- sommeAlt = sommeAlt - *matrices[i];
- if (i + 1 < argc)
- sommeAlt = sommeAlt + *matrices[i + 1];
- }
- printf("\nLa somme alternée de toutes les matrices vaut\n");
- sommeAlt.MATaffichage();
- CMatrice<double> produit = *(new CMatrice<double>(*(matrices[0])));
- for (int i = 1; i < argc - 1; i++)
- produit = produit * *matrices[i];
- printf("\nLe produit de toutes les matrices vaut\n");
- produit.MATaffichage();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement