📄 complex2.c
字号:
#include <stdio.h> struct complex { float real; float imag; };// define structure outside main in pre=processor area to make// it global. Otherwise functions will not know about itvoid add(struct complex *first, struct complex *second, struct complex *ans);int main (){ struct complex num1 = {1.7, 3.4}, num2, ans; num2.real = 5.1; num2.imag = 2.3; // or scanf("%f %f", num2.real, num2.imag); add(&num1, &num2, &ans); printf("(%5.2f, %5.2f) + (%5.2f, %5.2f) is (%5.2f, %5.2f)\n", num1.real, num1.imag, num2.real, num2.imag, ans.real, ans.imag); return 0;}void add (struct complex *first, struct complex *second, struct complex *result){ result -> real = first -> real + second -> real; (*result).imag = (*first).imag + (*second).imag;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -