Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. // Probabilistyka4.cpp: Określa punkt wejścia dla aplikacji konsoli.
  2. //
  3.  
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.  
  11. // Zadanie 1
  12.  
  13. double p1[3] = { 0.1,0.3,0.6 };
  14. double p2[3] = { 0.2,0.5,0.3 };
  15.  
  16. double out1[3][3];
  17.  
  18. for (int i = 0; i < 3; i++)
  19. for (int j = 0; j < 3; j++)
  20. out1[i][j] = p1[i] * p2[j];
  21.  
  22.  
  23. for (int i = 0; i < 3; i++)
  24. {
  25. for (int j = 0; j < 3; j++)
  26. cout << out1[i][j] << " ";
  27. cout << endl;
  28. }
  29.  
  30.  
  31.  
  32. //Zadanie 2
  33.  
  34. cout << endl << endl;
  35.  
  36. double c1[2] = { 0.6,0.4 };
  37.  
  38. double c2[2][2] = { {0.3,0.7},{0.1,0.9} };
  39.  
  40. double out2[2][2];
  41.  
  42. for (int i = 0; i < 2; i++)
  43. for (int j = 0; j < 2; j++)
  44. out2[i][j] = c2[i][j] * c1[i];
  45.  
  46.  
  47.  
  48.  
  49.  
  50. for (int i = 0; i < 2; i++)
  51. {
  52. for (int j = 0; j < 2; j++)
  53. cout << out2[i][j] << " ";
  54. cout << endl;
  55. }
  56.  
  57. //Zadanie 3
  58.  
  59. cout << endl << endl;
  60.  
  61.  
  62. double da = 0.00001;
  63. double dra = 0.95;
  64. double drna = 0.01;
  65.  
  66. double xr;
  67. double r;
  68.  
  69. r = da*dra + (1 - da)*drna;
  70.  
  71. xr = (da*dra) / r;
  72. cout << "Szansa na atak przy alarmie : " << xr << endl;
  73. cout << "szansa na brak ataku przy alarmie : " << 1 - xr;
  74.  
  75. double straty = xr * 500;
  76. cout << endl << straty << " mln" << endl;
  77.  
  78. if (straty > 1)
  79. cout << "Lepsza jest 1 strategia";
  80. else cout << "Lepsza jest 2 strategia";
  81.  
  82.  
  83.  
  84.  
  85. return 0;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement