Advertisement
Guest User

Untitled

a guest
Jun 13th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.70 KB | None | 0 0
  1. /* Funciones
  2. -prototipo
  3. -definicion
  4. -uso
  5.  
  6. #include <stdio.h>// conjunto de prototipos de las funciones que usamos en programacion xej scanf , printf, etc.
  7. #include <stdlib.h>
  8. struct com{
  9. float r,i;
  10. };
  11. struct com sumaZ(struct com,struct com);
  12.  
  13. int main()
  14. {struct com z,a,b,c;
  15.  
  16.   puts("ingrese parte real de un numero complejo a:");
  17.     scanf("%f",&a.r); fflush(stdin);
  18.     puts("ingrese parte imaginaria de un numero complejo a:");
  19.     scanf("%f",&a.i);
  20.     puts("ingrese parte real de un numero complejo b:");
  21.     scanf("%f",&b.r); fflush(stdin);
  22.     puts("ingrese parte imaginaria de un numero complejo b:");
  23.     scanf("%f",&b.i);
  24.     c=sumaZ(a,b);
  25.     printf("z=%.2f %.2fi",c.r,c.i);
  26.     return 0;
  27. }
  28.  struct com sumaZ(struct com w,struct com z){
  29.      struct com r;
  30.      r.r=w.r+z.r;
  31.      r.i=w.i+z.i;
  32.      return r ;
  33.  
  34.  };*/
  35.  
  36.  
  37.  
  38.  // multiplicacion de numeros complejos
  39.  
  40.  #include <stdio.h>// conjunto de prototipos de las funciones que usamos en programacion xej scanf , printf, etc.
  41. #include <stdlib.h>
  42.  
  43. typedef struct complejo{ //typedef sirve para establecer algo como tipo de dato
  44. float r,i;
  45. }com;
  46. com mulZ(com, com);
  47. int main()
  48. {com z,a,b,c;
  49.  
  50.     puts("ingrese parte real de un numero complejo a:");
  51.     scanf("%f",&a.r); fflush(stdin);
  52.     puts("ingrese parte imaginaria de un numero complejo a:");
  53.     scanf("%f",&a.i);
  54.     puts("ingrese parte real de un numero complejo b:");
  55.     scanf("%f",&b.r); fflush(stdin);
  56.     puts("ingrese parte imaginaria de un numero complejo b:");
  57.     scanf("%f",&b.i);
  58.     c=mulZ(a,b);
  59.     printf("z=%.2f %.2fi",c.r,c.i);
  60.     return 0;
  61. }
  62.  com mulZ(com w,com z){
  63.  com r ;
  64.  r.r=(w.r*z.r)-(w.i*z.i);
  65.  r.i=(w.r*z.i)+(w.i*z.r);
  66.  return r;
  67.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement