Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Funciones
- -prototipo
- -definicion
- -uso
- #include <stdio.h>// conjunto de prototipos de las funciones que usamos en programacion xej scanf , printf, etc.
- #include <stdlib.h>
- struct com{
- float r,i;
- };
- struct com sumaZ(struct com,struct com);
- int main()
- {struct com z,a,b,c;
- puts("ingrese parte real de un numero complejo a:");
- scanf("%f",&a.r); fflush(stdin);
- puts("ingrese parte imaginaria de un numero complejo a:");
- scanf("%f",&a.i);
- puts("ingrese parte real de un numero complejo b:");
- scanf("%f",&b.r); fflush(stdin);
- puts("ingrese parte imaginaria de un numero complejo b:");
- scanf("%f",&b.i);
- c=sumaZ(a,b);
- printf("z=%.2f %.2fi",c.r,c.i);
- return 0;
- }
- struct com sumaZ(struct com w,struct com z){
- struct com r;
- r.r=w.r+z.r;
- r.i=w.i+z.i;
- return r ;
- };*/
- // multiplicacion de numeros complejos
- #include <stdio.h>// conjunto de prototipos de las funciones que usamos en programacion xej scanf , printf, etc.
- #include <stdlib.h>
- typedef struct complejo{ //typedef sirve para establecer algo como tipo de dato
- float r,i;
- }com;
- com mulZ(com, com);
- int main()
- {com z,a,b,c;
- puts("ingrese parte real de un numero complejo a:");
- scanf("%f",&a.r); fflush(stdin);
- puts("ingrese parte imaginaria de un numero complejo a:");
- scanf("%f",&a.i);
- puts("ingrese parte real de un numero complejo b:");
- scanf("%f",&b.r); fflush(stdin);
- puts("ingrese parte imaginaria de un numero complejo b:");
- scanf("%f",&b.i);
- c=mulZ(a,b);
- printf("z=%.2f %.2fi",c.r,c.i);
- return 0;
- }
- com mulZ(com w,com z){
- com r ;
- r.r=(w.r*z.r)-(w.i*z.i);
- r.i=(w.r*z.i)+(w.i*z.r);
- return r;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement