Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.94 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. #include "complexNumber.h"
  5. #include "number.h"
  6. #include "realNumber.h"
  7. #include "matrix.h"
  8. #ifdef __cplusplus__
  9.     #include <cstdlib>
  10. #else
  11.     #include <stdlib.h>
  12. #endif
  13. using namespace std;
  14. void demo();
  15. void real();
  16. /*
  17. void acls();
  18. void pakc();
  19. void menu();
  20. */
  21.  
  22. int main()
  23. {
  24.     cout << "aCal version 0.1.0 by Agata Głogowska\n"
  25.             "Program for matrix and complex operations\n";
  26.     char option = ' ';
  27.     srand (static_cast <unsigned> (time(0)));
  28.     //pakc();
  29.     //acls();
  30.     for (;;) {
  31.         cout << "You can:\n"
  32.                 " · press 'd' for demo of program functions\n"
  33.                 " · press 'r' for make your own calculations\n"
  34.                 " · press 'c' for close program\n";
  35.         cin >> option;
  36.         switch (option) {
  37.         case 'd':
  38.             demo();
  39.             break;
  40.         case 'r':
  41.             real();
  42.             break;
  43.         case 'c':
  44.             return 0;
  45.             break;
  46.         default:
  47.             //acls();
  48.             cout << "Please press valid key...\n\n";
  49.             break;
  50.         }
  51.     }
  52. }
  53. void demo() {
  54. /*
  55.     acls();
  56.     complexNumber a(0.5, 0.7);
  57.     complexNumber b(5.3, 4.2);
  58.     float c = 11.3;
  59.     */
  60.     complexNumber** tabA = new complexNumber* [3];
  61.     for (int i = 0; i < 3; i++) {
  62.         tabA[i] = new complexNumber[2];
  63.         for (int j = 0; j < 2; j++){
  64.             complexNumber tmp((10 + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(10-20)))),
  65.                               (10 + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(10-20)))));
  66.             tabA[i][j] = tmp;
  67.         }
  68.     }
  69.     matrix<complexNumber> matA(2, 3, tabA);
  70.     matA.show();
  71.     /*
  72.     complexNumber** tabB = new complexNumber* [3];
  73.     for (int i = 0; i < 3; i++) {
  74.         tabB[i] = new complexNumber[2];
  75.         for (int j = 0; j < 2; j++){
  76.         complexNumber tmp((10 + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(10-20)))),
  77.                           (10 + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(10-20)))));
  78.             tabB[i][j] = tmp;
  79.         }
  80.     }
  81.     matrix<complexNumber> matB(3, 2, tabB);
  82.     complexNumber tabC[2][2];
  83.     for (int i = 0; i < 2; i++) {
  84.         for (int j = 0; j < 2; j++){
  85.             complexNumber tmp((10 + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(10-20)))),
  86.                               (10 + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(10-20)))));
  87.             tabC[i][j] = tmp;
  88.         }
  89.     }
  90.     complexNumber tabD[2][1];
  91.     for (int i = 0; i < 2; i++) {
  92.         for (int j = 0; j < 1; j++){
  93.             complexNumber tmp((10 + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(10-20)))),
  94.                               (10 + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(10-20)))));
  95.             tabD[i][j] = tmp;
  96.         }
  97.     }
  98.  
  99.  
  100.     cout << "Complex calculations:\n"
  101.             "   a = " << a << "\n" <<
  102.             "   b = " << b << "\n" <<
  103.             "   c = " << c << "\n\n\n" <<
  104.             "   " << a << " + " << b << " = " << a+b << "\n" <<
  105.             "   " << a << " - " << b << " = " << a-b << "\n"<<
  106.             "   " << a << " * " << b << " = " << a*b << "\n" <<
  107.             "   " << a << " * " << c << "     = " << a*c << "\n" <<
  108.             "   " << a << " / " << b << " = " << a/b << "\n" <<
  109.             "   conjugate  of a = " << conjugate(a)  << "\n" <<
  110.             "   reciprocal of a = " << reciprocal(a) << "\n" <<
  111.             "   magnitude  of a = " << a.Magnitude() << "\n" <<
  112.             "Matrix calculations:\n";
  113.     pakc();
  114.     */
  115. }
  116.  
  117. void real() {
  118. }
  119. /*
  120. void acls() {
  121.     if (system("CLS")) system("clear");
  122. }
  123. void pakc() {
  124.     char c = 'a';
  125.     while (c != 'c'){
  126.         cout << "\nPress c to continue...\n";
  127.         cin  >> c;
  128.         acls();
  129.     };
  130. }
  131. void menu(){}
  132. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement