Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- using namespace std;
- void leer(float &x,float &y, int i){
- cout<<"Numero "<<i<<endl;
- cout<<" Parte Real "<<endl;
- cin>>x;
- cout<<" Parte Imaginaria "<<endl;
- cin>>y;}
- void escribe(float x,float y){
- cout<<"("<<x<<"+"<<y<<"i)";}
- void sumar(){
- float x1,y1,x2,y2;
- //Lee 1
- leer(x1,y1,1);
- //Lee 2
- leer(x2,y2,2);
- //Dibuja Numero
- escribe(x1,y1);
- cout<<"+";
- escribe(x2,y2);
- cout<<"=";
- escribe(x1+x2,y1+y2);}
- void restar(){
- float x1,y1,x2,y2;
- //Lee 1
- leer(x1,y1,1);
- //Lee 2
- leer(x2,y2,2);
- //Dibuja Numero
- escribe(x1,y1);
- cout<<"-";
- escribe(x2,y2);
- cout<<"=";
- escribe(x1-x2,y1-y2);
- }
- int main(){
- char op;
- cout<<endl;
- cout<<" MENU"<<endl;
- cout<<" ------"<<endl;
- cout<<"A. Sumar 2 complejos."<<endl;
- cout<<"B. Restar 2 complejos."<<endl;
- cout<<"X. Salir del programa."<<endl;
- cout<<endl;
- while(true){
- cout<<"Ingrese opcion."<<endl;
- cin>>op;
- switch(op){
- case 'A':case 'a':sumar();break;
- case 'B':case'b':restar();break;
- case 'X':case'x':return 0;
- default:cout<<"Error."<<endl;
- }
- }
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement