Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream> //autor: Julia Mroczkowska 3b2
- #include <cmath>
- #include <cstdlib>
- #include <iomanip>
- using namespace std;
- int main ()
- {
- cout<<"Program sluzy do obliczenia natezenia obwodu za pomoca macierzy metoda Cramera"<<endl;
- cout<<"\t "<<endl;
- cout<<"\t I2 ____ rw +| - E1 "<<endl;
- cout<<"\t .--------<----|____|---------| |-----------------."<<endl;
- cout<<"\t | | |"<<endl;
- cout<<"\t | |"<<endl;
- cout<<"\t | |"<<endl;
- cout<<"\t | |"<<endl;
- cout<<"\t | |"<<endl;
- cout<<"\t | I1 _____ R2 |"<<endl;
- cout<<"\t o--------<-----------|_____|---------------------o"<<endl;
- cout<<"\t | |"<<endl;
- cout<<"\t | |"<<endl;
- cout<<"\t | |"<<endl;
- cout<<"\t | |"<<endl;
- cout<<"\t | |"<<endl;
- cout<<"\t | R1 ______ E1 + | - ____ rw I |"<<endl;
- cout<<"\t '-----|______|----------| |----|____|------->----'"<<endl;
- cout<<"\t | "<<endl;
- cout<<"\t "<<endl;
- cout<<endl;
- for (int i; i!=0;)
- {
- float W0, W1, W2, a, b, c, d, e, f, g;
- cout<<endl<<endl;
- cout<<"Podaj wartosc SEM zrodla napiecia E1 (w woltach):"<<endl;
- cout<<"E1 = ";
- cin>>d;
- cout<<endl;
- cout<<"Podaj wartosc SEM zrodla napiecia E2 (w woltach):"<<endl;
- cout<<"E2 = ";
- cin>>e;
- cout<<endl;
- cout<<"Podaj wartosc oporu wewnetrznego zrodla (w omach):"<<endl;
- cout<<"rw = ";
- cin>>a;
- cout<<endl;
- cout<<"Podaj wartosc oporu rezystora R1 (w omach):"<<endl;
- cout<<"R1 = ";
- cin>>b;
- cout<<endl;
- cout<<"Podaj wartosc oporu rezystora R2 (w omach):"<<endl;
- cout<<"R2 = ";
- cin>>c;
- cout<<endl;
- W0 =(b+a)*a - c*(b+2*a);
- W1 =(e-d)*a - e*(b+2*a);
- W2 =(b+a)*e - c*(e-d);
- if( W0 != 0 )
- {
- f = W1 / W0;
- g = W2 / W0;
- cout<<"Natezenie oczkowe nr 1 (I1) = "<<setprecision( 2 )<<f<<" A"<<endl;
- cout<<"Natezenie oczkowe nr 2 (I2) = "<<setprecision( 2 )<<g<<" A"<<endl;
- }
- else
- {
- cout << "Mozliwe zwarcie!" << endl;
- }
- cout<<endl<<endl;
- cout<<"Jeszcze raz?"<<endl;
- cout<<"0 - Nie, wyjdz z programu"<<endl;
- cout<<"1 - Tak"<<endl;
- cin>>i;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement