Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void GetSubstraction(int& a, int b)
- {
- a-=b;
- }
- void GetSubstraction(int &aReal, int &aComplex, int bReal, int bComplex)
- {
- aReal-=bReal;
- aComplex-=bComplex;
- }
- int main()
- {
- char choise;
- cout<<"Press r to substraction two real numbers or c to complex: ";
- cin >>choise;
- switch (choise)
- {
- case 'r':
- int a, b;
- cout<<"Enter first real number: ";
- cin>>a;
- cout<<"Enter second real number: ";
- cin >>b;
- GetSubstraction(a,b);
- cout<<"Result: "<<a<<endl;
- break;
- case 'c':
- int aReal, aComplex, bReal, bComplex;
- cout<<"Enter real part of first number: ";
- cin>>aReal;
- cout<<"Enter complex part of first number: ";
- cin>>aComplex;
- cout<<"Enter real part of second number: ";
- cin>>bReal;
- cout<<"Enter complex part of second number: ";
- cin>>bComplex;
- GetSubstraction(aReal,aComplex,bReal,bComplex);
- if(aComplex>0)
- cout<<"Result: "<<aReal<<"+("<<bComplex<<")i"<<endl;
- else if(aComplex<0)
- cout<<"Result: "<<aReal<<"-("<<bComplex*(-1)<<")i"<<endl;
- else
- cout<<"Result: "<<aReal<<endl;
- break;
- default:
- cout<< "Wrong pick"<<endl;
- break;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement