Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #define pi 3.14159265/180
- struct complexo{
- float real;
- float imaginario;
- };
- struct complexo le_complexo(){
- struct complexo c;
- printf("insira um nr real \n");
- scanf("%f", c.real);
- printf("insira um nr imaginario");
- scanf("%f", c.imaginario);
- return c;
- }
- struct complexo soma_complexo(struct complexo c1, struct complexo c2){
- struct complexo soma;
- soma.real = c1.real + c2.real;
- soma.imaginario = c1.imaginario + c2.imaginario;
- return soma;
- }
- void escreve_complexo(struct complexo c){
- printf("%f + i%f", c.real, c.imaginario);
- }
- double modulo_complexo(struct complexo c){
- double resultado = (c.real*c.real)+(c.imaginario*c.imaginario);
- return sqrt(resultado);
- }
- double argumento_complexo(struct complexo c){
- if(fabs(c.real) != 0){
- return atan(c.imaginario/(c.real));
- }
- else{
- return asin(c.imaginario/modulo_complexo(c));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement