Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. #define pi 3.14159265/180
  5.  
  6. struct complexo{
  7. float real;
  8. float imaginario;
  9. };
  10.  
  11.  
  12. struct complexo le_complexo(){
  13. struct complexo c;
  14. printf("insira um nr real \n");
  15. scanf("%f", c.real);
  16. printf("insira um nr imaginario");
  17. scanf("%f", c.imaginario);
  18. return c;
  19. }
  20.  
  21. struct complexo soma_complexo(struct complexo c1, struct complexo c2){
  22. struct complexo soma;
  23. soma.real = c1.real + c2.real;
  24. soma.imaginario = c1.imaginario + c2.imaginario;
  25. return soma;
  26. }
  27.  
  28. void escreve_complexo(struct complexo c){
  29. printf("%f + i%f", c.real, c.imaginario);
  30. }
  31.  
  32.  
  33. double modulo_complexo(struct complexo c){
  34. double resultado = (c.real*c.real)+(c.imaginario*c.imaginario);
  35. return sqrt(resultado);
  36. }
  37.  
  38. double argumento_complexo(struct complexo c){
  39. if(fabs(c.real) != 0){
  40. return atan(c.imaginario/(c.real));
  41. }
  42. else{
  43. return asin(c.imaginario/modulo_complexo(c));
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement