Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- using namespace std;
- struct TComplex
- {
- float Re;
- float Im;
- };
- void suma(TComplex jeden, TComplex druga)
- {
- TComplex su;
- su.Re=jeden.Re+druga.Re;
- su.Im=jeden.Im+druga.Im;
- cout<<"\nCzesc rzeczywista: "<<su.Re<<"\nCzesc urojona: "<<su.Im<<endl;
- };
- void iloczyn(TComplex jeden, TComplex druga)
- {
- TComplex ilo;
- ilo.Re=(jeden.Re*druga.Re-jeden.Im*druga.Im);
- ilo.Im=(jeden.Re*druga.Im+druga.Re*jeden.Im);
- cout<<"Czesc rzeczywista: "<<ilo.Re<<" "<<"\nCzesc urojona: "<<ilo.Im<<endl;
- };
- void drukuj(TComplex jeden, TComplex druga)
- {
- TComplex dr;
- TComplex dr2;
- dr.Re=jeden.Re;
- dr.Im=jeden.Im;
- dr2.Re=druga.Re;
- dr2.Im=druga.Im;
- cout<<dr.Re<< "+" <<dr.Im<< "j" <<", "5;
- cout<<dr2.Re<< "+" <<dr2.Im<< "j" <<endl;
- };
- int main(int argc, char *argv[])
- {
- TComplex pierwsza;
- TComplex druga;
- cout<<"Podaj pierwsza liczbe\n";
- cin>>pierwsza.Re;
- cin>>pierwsza.Im;
- cout<<"Podaj druga liczbe\n";
- cin>>druga.Re;
- cin>>druga.Im;
- cout<<"suma to: ";
- suma(pierwsza, druga);
- cout<<"iloczyn to: \n";
- iloczyn(pierwsza, druga);
- cout<<endl;
- drukuj(pierwsza, druga);
- system("PAUSE");
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement