Advertisement
NoExisteLink

PROGRA30-05-2014

May 30th, 2014
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. using namespace std;
  4. void leer(float &x,float &y, int i){
  5. cout<<"Numero "<<i<<endl;
  6. cout<<" Parte Real "<<endl;
  7. cin>>x;
  8. cout<<" Parte Imaginaria "<<endl;
  9. cin>>y;}
  10.  
  11. void escribe(float x,float y){
  12. cout<<"("<<x<<"+"<<y<<"i)";}
  13.  
  14. void sumar(){
  15. float x1,y1,x2,y2;
  16. //Lee 1
  17. leer(x1,y1,1);
  18. //Lee 2
  19. leer(x2,y2,2);
  20. //Dibuja Numero
  21. escribe(x1,y1);
  22. cout<<"+";
  23. escribe(x2,y2);
  24. cout<<"=";
  25. escribe(x1+x2,y1+y2);}
  26. void restar(){
  27. float x1,y1,x2,y2;
  28. //Lee 1
  29. leer(x1,y1,1);
  30. //Lee 2
  31. leer(x2,y2,2);
  32. //Dibuja Numero
  33. escribe(x1,y1);
  34. cout<<"-";
  35. escribe(x2,y2);
  36. cout<<"=";
  37. escribe(x1-x2,y1-y2);
  38. }
  39.  
  40.  
  41. int main(){
  42. char op;
  43. cout<<endl;
  44. cout<<" MENU"<<endl;
  45. cout<<" ------"<<endl;
  46. cout<<"A. Sumar 2 complejos."<<endl;
  47. cout<<"B. Restar 2 complejos."<<endl;
  48. cout<<"X. Salir del programa."<<endl;
  49. cout<<endl;
  50. while(true){
  51. cout<<"Ingrese opcion."<<endl;
  52. cin>>op;
  53. switch(op){
  54. case 'A':case 'a':sumar();break;
  55. case 'B':case'b':restar();break;
  56. case 'X':case'x':return 0;
  57. default:cout<<"Error."<<endl;
  58. }
  59. }
  60. _getch();
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement