Add all the A tasks
This commit is contained in:
parent
2dd7375f96
commit
051504d65b
1608 changed files with 18584 additions and 0 deletions
32
Task/Arithmetic-Complex/C/arithmetic-complex-1.c
Normal file
32
Task/Arithmetic-Complex/C/arithmetic-complex-1.c
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#include <complex.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void cprint(double complex c)
|
||||
{
|
||||
printf("%f%+fI", creal(c), cimag(c));
|
||||
}
|
||||
void complex_operations() {
|
||||
double complex a = 1.0 + 1.0I;
|
||||
double complex b = 3.14159 + 1.2I;
|
||||
|
||||
double complex c;
|
||||
|
||||
printf("\na="); cprint(a);
|
||||
printf("\nb="); cprint(b);
|
||||
|
||||
// addition
|
||||
c = a + b;
|
||||
printf("\na+b="); cprint(c);
|
||||
// multiplication
|
||||
c = a * b;
|
||||
printf("\na*b="); cprint(c);
|
||||
// inversion
|
||||
c = 1.0 / a;
|
||||
printf("\n1/c="); cprint(c);
|
||||
// negation
|
||||
c = -a;
|
||||
printf("\n-a="); cprint(c);
|
||||
// conjugate
|
||||
c = conj(a);
|
||||
printf("\nconj a="); cprint(c); printf("\n");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue