0664jester
Mitglied
Ich habe hier diese Funktionen geschrieben.
bei void calc bin ich mir nicht sicher ob ich pointer soll nehmen für (complex *complex, float *r, float *phi), oder nicht?
Gruß,
jester
bei void calc bin ich mir nicht sicher ob ich pointer soll nehmen für (complex *complex, float *r, float *phi), oder nicht?
Code:
#include <stdio.h>
//
///creat struct for
//
typedef struct _complex_
{
float real_;
float imag_;
} Complex;
void calc(Complex *complex, float *r, float *phi)
{
*r = sqrt (complex -> real_ * complex -> real_ + complex -> imag_ *
complex -> imag_); // r=sqrt(a²+b²)
*phi = atan(complex -> imag_ / complex -> real_); //arctan(b/a)
}
void output(const Complex *complex)
{
float r;
float phi;
calc(complex, &r, &phi);
printf("%f, %f\n", r, phi);
}
int main ()
...
Gruß,
jester