debut TP21
This commit is contained in:
BIN
DEV1.1/TP19/complexe
Executable file
BIN
DEV1.1/TP19/complexe
Executable file
Binary file not shown.
49
DEV1.1/TP19/complexe.c
Normal file
49
DEV1.1/TP19/complexe.c
Normal file
@@ -0,0 +1,49 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user