54 lines
850 B
C
54 lines
850 B
C
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <math.h>
|
||
|
|
||
|
struct nbrcomplex{
|
||
|
|
||
|
float x;
|
||
|
float y;
|
||
|
};
|
||
|
|
||
|
typedef struct nbrcomplex complex;
|
||
|
|
||
|
void afficher(complex z){
|
||
|
printf("%f + %fi\n", z.x, z.y);
|
||
|
}
|
||
|
|
||
|
float module(complex z){
|
||
|
float res = sqrt(pow(z.x, 2)+pow(z.y, 2));
|
||
|
float resrac = pow(res, 0.5);
|
||
|
return resrac;
|
||
|
}
|
||
|
|
||
|
complex inverse(complex z){
|
||
|
complex a;
|
||
|
a.x = z.x/pow(module(z), 2);
|
||
|
a.y = z.y/pow(module(z), 2);
|
||
|
return a;
|
||
|
}
|
||
|
|
||
|
complex conjugue(complex z){
|
||
|
complex b;
|
||
|
b.x = z.x;
|
||
|
b.y = -z.y;
|
||
|
return b;
|
||
|
}
|
||
|
|
||
|
int main(int argc, char const* argv[]){
|
||
|
complex z = {3,8};
|
||
|
complex a, b, c;
|
||
|
|
||
|
afficher(z);
|
||
|
|
||
|
a = z;
|
||
|
module(a);
|
||
|
printf("|z| = %f\n", a);
|
||
|
|
||
|
b = conjugue(z);
|
||
|
afficher(b);
|
||
|
printf("conjugue = %f\n", b);
|
||
|
|
||
|
c = inverse(z);
|
||
|
afficher(c);
|
||
|
return EXIT_SUCCESS;
|
||
|
}
|