Operaciones con numeros complejos en c
//Programa: Uso de estructuras
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<stdlib.h>
struct complejo
{
double real;double imag;
};
complejo sumar(complejo X, complejo Y);
complejo sumar(complejo X, complejo Y)
{
struct complejo Z;
Z.real= X.real + Y.real;Z.imag= X.imag + Y.imag;
return Z;
}
main()
{
struct complejo A,B,C;
int x, s;
printf("\n\t Sumade dos numeros complejos");
printf("\n\n Introduce los valores para A: ");
scanf("%lf,%lf", &A.real,&A.imag);
printf("A: %lf %lf i",A.real, A.imag);
printf("\n Introduce los valores para B: ");
scanf("%lf, %lf", & B.real, & B.imag);
printf("B: %lf %lf i", B.real, B.imag);C=sumar(A,B);
printf("\n Resultado: %lf %lf i", C.real, C.imag);
getch();
printf("\n\nPara sumar nuevamente presionaenter, para salir presiona S");
scanf("%i", &x);
return 0;
}
Resta
//Programa: Uso de estructuras
//Solución: RestaComp.cpp#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<stdlib.h>
struct complejo
{
double real;
double imag;
};
complejorestar(complejo X, complejo Y);
complejo restar(complejo X, complejo Y)
{
struct complejo Z;
Z.real= X.real - Y.real;
Z.imag= X.imag - Y.imag;
returnZ;
}
main()
{
struct complejo A,B,C;
clrscr();
printf("\n\t Resta de dos numeros complejos");
printf("\n\n...
Regístrate para leer el documento completo.