diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2025-10-11 22:19:00 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2025-10-11 22:19:00 +0200 |
| commit | 73c2b00a10c5786ddeeacc915e233fd4df1c9321 (patch) | |
| tree | e299ea4e8ac161b2b21170172ff8f182c1c3fe1a /rushs/tinyprintf/handling_complex | |
| parent | c9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c (diff) | |
fix: evalexpr & tinyprintf contenaient toute la piscine
Diffstat (limited to 'rushs/tinyprintf/handling_complex')
| -rw-r--r-- | rushs/tinyprintf/handling_complex/complex.c | 51 | ||||
| -rw-r--r-- | rushs/tinyprintf/handling_complex/complex.h | 20 |
2 files changed, 0 insertions, 71 deletions
diff --git a/rushs/tinyprintf/handling_complex/complex.c b/rushs/tinyprintf/handling_complex/complex.c deleted file mode 100644 index 79a10be..0000000 --- a/rushs/tinyprintf/handling_complex/complex.c +++ /dev/null @@ -1,51 +0,0 @@ -#include "complex.h" - -#include <stdio.h> - -void print_complex(struct complex a) -{ - printf("complex(%.2f ", a.real); - - if (a.img < 0) - { - printf("- %.2fi", -a.img); - } - else - { - printf("+ %.2fi", a.img); - } - printf(")\n"); -} - -struct complex neg_complex(struct complex a) -{ - struct complex z = { -a.real, -a.img }; - return z; -} - -struct complex add_complex(struct complex a, struct complex b) -{ - struct complex z = { a.real + b.real, a.img + b.img }; - return z; -} - -struct complex sub_complex(struct complex a, struct complex b) -{ - return add_complex(a, neg_complex(b)); -} - -struct complex mul_complex(struct complex a, struct complex b) -{ - struct complex z = { a.real * b.real - a.img * b.img, - a.real * b.img + a.img * b.real }; - return z; -} - -struct complex div_complex(struct complex a, struct complex b) -{ - struct complex z = { - (a.real * b.real + a.img * b.img) / (b.real * b.real + b.img * b.img), - (a.img * b.real - a.real * b.img) / (b.real * b.real + b.img * b.img) - }; - return z; -} diff --git a/rushs/tinyprintf/handling_complex/complex.h b/rushs/tinyprintf/handling_complex/complex.h deleted file mode 100644 index c562810..0000000 --- a/rushs/tinyprintf/handling_complex/complex.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef COMPLEX_H -#define COMPLEX_H - -struct complex -{ - float real; - float img; -}; - -// Print -void print_complex(struct complex a); - -// Operations -struct complex neg_complex(struct complex a); -struct complex add_complex(struct complex a, struct complex b); -struct complex sub_complex(struct complex a, struct complex b); -struct complex mul_complex(struct complex a, struct complex b); -struct complex div_complex(struct complex a, struct complex b); - -#endif /* !COMPLEX_H */ |
