Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. #include <iostream> //autor: Julia Mroczkowska 3b2
  2. #include <cmath>
  3. #include <cstdlib>
  4. #include <iomanip>
  5.  
  6. using namespace std;
  7.  
  8. int main ()
  9.  
  10. {
  11. cout<<"Program sluzy do obliczenia natezenia obwodu za pomoca macierzy metoda Cramera"<<endl;
  12. cout<<"\t "<<endl;
  13. cout<<"\t I2 ____ rw +| - E1 "<<endl;
  14. cout<<"\t .--------<----|____|---------| |-----------------."<<endl;
  15. cout<<"\t | | |"<<endl;
  16. cout<<"\t | |"<<endl;
  17. cout<<"\t | |"<<endl;
  18. cout<<"\t | |"<<endl;
  19. cout<<"\t | |"<<endl;
  20. cout<<"\t | I1 _____ R2 |"<<endl;
  21. cout<<"\t o--------<-----------|_____|---------------------o"<<endl;
  22. cout<<"\t | |"<<endl;
  23. cout<<"\t | |"<<endl;
  24. cout<<"\t | |"<<endl;
  25. cout<<"\t | |"<<endl;
  26. cout<<"\t | |"<<endl;
  27. cout<<"\t | R1 ______ E1 + | - ____ rw I |"<<endl;
  28. cout<<"\t '-----|______|----------| |----|____|------->----'"<<endl;
  29. cout<<"\t | "<<endl;
  30. cout<<"\t "<<endl;
  31. cout<<endl;
  32.  
  33. for (int i; i!=0;)
  34. {
  35. float W0, W1, W2, a, b, c, d, e, f, g;
  36.  
  37. cout<<endl<<endl;
  38.  
  39. cout<<"Podaj wartosc SEM zrodla napiecia E1 (w woltach):"<<endl;
  40. cout<<"E1 = ";
  41. cin>>d;
  42. cout<<endl;
  43.  
  44. cout<<"Podaj wartosc SEM zrodla napiecia E2 (w woltach):"<<endl;
  45. cout<<"E2 = ";
  46. cin>>e;
  47. cout<<endl;
  48.  
  49. cout<<"Podaj wartosc oporu wewnetrznego zrodla (w omach):"<<endl;
  50. cout<<"rw = ";
  51. cin>>a;
  52. cout<<endl;
  53.  
  54. cout<<"Podaj wartosc oporu rezystora R1 (w omach):"<<endl;
  55. cout<<"R1 = ";
  56. cin>>b;
  57. cout<<endl;
  58.  
  59. cout<<"Podaj wartosc oporu rezystora R2 (w omach):"<<endl;
  60. cout<<"R2 = ";
  61. cin>>c;
  62. cout<<endl;
  63.  
  64. W0 =(b+a)*a - c*(b+2*a);
  65. W1 =(e-d)*a - e*(b+2*a);
  66. W2 =(b+a)*e - c*(e-d);
  67.  
  68.  
  69. if( W0 != 0 )
  70. {
  71. f = W1 / W0;
  72. g = W2 / W0;
  73. cout<<"Natezenie oczkowe nr 1 (I1) = "<<setprecision( 2 )<<f<<" A"<<endl;
  74. cout<<"Natezenie oczkowe nr 2 (I2) = "<<setprecision( 2 )<<g<<" A"<<endl;
  75. }
  76.  
  77. else
  78. {
  79. cout << "Mozliwe zwarcie!" << endl;
  80. }
  81.  
  82. cout<<endl<<endl;
  83. cout<<"Jeszcze raz?"<<endl;
  84. cout<<"0 - Nie, wyjdz z programu"<<endl;
  85. cout<<"1 - Tak"<<endl;
  86. cin>>i;
  87.  
  88. }
  89.  
  90. return 0;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement