1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-11-27 08:26:20 +00:00
202401-programming-assignments/【实践课内】12.函数3/6-1 使用函数计算两个复数之和与之积.c

12 lines
357 B
C
Raw Permalink Normal View History

2024-11-27 02:25:12 +00:00
// double result_real, result_imag;
void complex_add(double real1, double imag1, double real2, double imag2) {
result_real = real1 + real2;
result_imag = imag1 + imag2;
}
void complex_prod(double real1, double imag1, double real2, double imag2) {
result_real = real1 * real2 - imag1 * imag2;
result_imag = real1 * imag2 + real2 * imag1;
}