Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.51 KB | None | 0 0
  1. #define _USE_MATH_DEFINES
  2. #include <iostream>
  3. #include <string.h>
  4. #include <math.h>
  5. #include <cmath>
  6. #include <algorithm>
  7. #include <iomanip>
  8. #include <tgmath.h>
  9. #include <fcntl.h>
  10. #include <stdio.h>
  11. #include <wchar.h>
  12. #include <conio.h>
  13. using namespace std;
  14. char cheie[8];
  15. double Ni[7];
  16. double A,B,C,D,omega1,omega0,omega2,omega3,omega6;
  17. double k1;
  18.  
  19.  
  20. double factorial(double n)
  21. {
  22.     if(n > 1)
  23.         return n * factorial(n - 1.0);
  24.     else
  25.         return 1.0;
  26. }
  27.  
  28. wchar_t *GetWC(const char *c)
  29. {
  30.     const size_t cSize = strlen(c)+1;
  31.     wchar_t* wc = new wchar_t[cSize];
  32.     mbstowcs (wc, c, cSize);
  33.  
  34.     return wc;
  35. }
  36.  
  37. int main(void)
  38. {
  39.     wcout.precision(5);
  40.     wcout<<fixed;
  41.     _setmode(_fileno(stdout), 0x10000);
  42.     wchar_t *pi = L"\u03C0";
  43.     wchar_t *omega = L"\u03A9";
  44.     wchar_t *s[10];
  45.     s[0] = L"\u2080";
  46.     s[1] = L"\u2081";
  47.     s[3] = L"\u2083";
  48.     s[4] = L"\u2084";
  49.     s[5] = L"\u2085";
  50.     s[2] = L"\u2082";
  51.     s[6] = L"\u2086";
  52.     s[7] = L"\u2087";
  53.     s[8] = L"\u2088";
  54.     s[9] = L"\u2089";
  55.     //const char litere[27] = "abcdefghijklmnopqrstuvwxyz";
  56.     wcout<<"Introdu cheia : ";
  57.     cin.get(cheie,8);
  58.     cin.get();
  59.     wcout<<L" ---Simbol convolutie - \u22C7 --- "<<endl;
  60.     Ni[0] = (double)cheie[0] - 96.0;
  61.     Ni[1] = (double)cheie[1] - 96.0;
  62.     Ni[2] = (double)cheie[2] - 96.0;
  63.     Ni[3] = (double)cheie[3] - 96.0;
  64.     Ni[4] = (double)cheie[4] - 96.0;
  65.     Ni[5] = (double)cheie[5] - 96.0;
  66.     Ni[6] = (double)cheie[6] - 96.0;
  67.     k1 = 1.0 + fmod(Ni[5],3);
  68.     omega1 = fmod(Ni[0],(double)M_PI); // omega1 = 1
  69.     omega2 = fmod(Ni[1],(double)M_PI);
  70.     omega0 = min(omega1,omega2);
  71.     omega3 = fmod(Ni[2],(double)M_PI); // omega2 = 2
  72.     omega6 = fmod(Ni[5],(double)M_PI);
  73. //    wcout<<"!!! !!!"<<sub;
  74.     for(unsigned int i=0; i<strlen(cheie); i++)
  75.         wcout<<cheie[i]<<" ";
  76.  
  77.     wcout<<'\n';
  78.  
  79.     for(int i=0; i<7; i++)
  80.         wcout<<Ni[i]<<" ";
  81.  
  82.     wcout<<'\n';
  83.  
  84.     double tempN6 = Ni[6];
  85.  
  86.     A = 1.0 / ( cos ( Ni[0]*Ni[1] ) );
  87.  
  88.     double AA = A;
  89.  
  90.     B = M_PI / ( sin( Ni[2]*Ni[3] ) );
  91.     C = exp(Ni[4])/factorial(k1-1);
  92.     D = M_PI / sin(Ni[6]);
  93.     Ni[6] = tempN6;
  94.  
  95.     wcout<<L"\n1.";
  96.     wcout<<L"\na) "<<L"A = "<<AA<<" 2A = "<<2.0*AA<<'\n'<<L"y(t) = "<<L"2 * "<<AA<<L" * cos[("<<Ni[0]<<L" * (t+"<<Ni[1]<<L"))] * x(t+"<<Ni[1]<<L")\n\n"; // AICI A = 5 WTF????
  97.     wcout<<L"b) "<<L"B = "<<B<<'\n'<<L"y(t) = "<<0.0-(B/M_PI)<<L" * x(t) \u22C7 sin("<<Ni[2]<<L"*t)\n\n";
  98.     wcout<<L"c) "<<L"C = "<<C<<'\n'<<L"y(t) = x(t) \u22C7 ["<<C<<L" * (t^"<<k1-1.0<<L")/("<<factorial(k1-1.0)    <<L") * e^("<<0.0-Ni[4]<<L"*t) * \u03C3(t)]\n\n";
  99.     wcout<<L"d) "<<L"D = "<<D<<'\n'<<L"y(t) = x(t) \u22C7 "<<D<<L" * [ sin("<<Ni[6]<<L"*t) / ("<<pi<<L"*t) ]\n\n";
  100.     wcout<<L"2.\n";
  101.     wcout<<L"a) h[n] = sin("<<omega1<<L"*n) / "<<pi<<L"*n\n";
  102.     wcout<<L"Y1( \u03A9 ) = "<<M_PI/omega2<<L" * p"<<s[(int)omega0]<<'('<<omega<<L")\n";
  103.     wcout<<L"y1[n] = sin("<<omega0<<L"*n) / ("<<omega2<<L"*n)\n\n";
  104.  
  105.     if(omega1<omega3)
  106.     {
  107.         wcout<<L"b) Y2(omega) = 0\n";
  108.         wcout<<L"y2[n] = 0\n";
  109.     }
  110.     else
  111.     {
  112.         wcout<<L"b) Y2(omega) = "<<pi<<L"/ j * [\u1E9F(omega - "<<omega3<<L") - \u1E9F(omega + "<<omega3<<L")]\n";
  113.         wcout<<L"y2[n] = sin("<<omega3<<L"*n)\n";
  114.     }
  115.  
  116.     /*for(int i=0;i<8;i++)
  117.         cout<<Ni[i]<<" ";
  118.     */
  119.  
  120.     double n5 = Ni[4];
  121.     double n4 = Ni[3];
  122.     double n7 = Ni[6];
  123.     double t;
  124.     t = n5/(2.0*n4);
  125.     double t1;
  126.     t1 = 1.0/(2.0*n4);
  127.     double alfa, beta;
  128.     double iarA, iarB;
  129.  
  130.     alfa = t1;
  131.     beta = 1.0/(1.0+n7);
  132.     iarA = alfa / (alfa-beta);
  133.     iarB = 0.0 - beta / (alfa - beta);
  134.  
  135.     /*wcout<<" \u03B1 = "<<alfa<<endl;
  136.     wcout<<" \u03B2 = "<<beta<<endl;*/
  137.  
  138.     wcout<<L"\n3.\na) H(\u03A9) = "<<t<<L" * 1 / ( 1 - "<<t1<<L" * e ^ (-j*\u03A9)\n\n";
  139.     wcout<<L"b) h[n] = "<<t<<L" * ( 1 / "<<2.0*n4<<L" ) ^ n * \u03C3[n]\n\n";
  140.     wcout<<L"c) X1(\u03A9) = "<<pi<<L" / j * [\u1E9F(\u03A9 - "<<omega6<<L") - \u1E9F(\u03A9 + "<<omega6<<L")]\n";
  141.     wcout<<L"y1[n] = "<<(n5/(sqrt(2.0 * n4 - pow(cos(omega6),2.0) + pow(sin(omega6),2.0))))<<L" * sin("<<omega6<<L"*n - "<<atan(sin(omega6)/(2.0*n4-cos(omega6)))<<L")\n\n";
  142.     wcout<<L"d) X2( \u03A9 ) = 1 / ( 1 - "<<beta<<L" * e ^ (-j\u03A9) )\n";
  143.     wcout<<L"y2[n] =";
  144.  
  145.     if(alfa != beta)
  146.         wcout << n5*t1 << " * ( " << iarA << " * " << alfa << "^n + " << iarB << " * " << beta <<L"^n ) *  \u03C3[n]";
  147.     else
  148.         wcout <<n5<<" * (n+1) * "<<alfa<<L"^(n+1) *  \u03C3[n]";
  149.     getch();
  150.     return 0;
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement