⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 complex.c

📁 C源码集
💻 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 itstruct complex add(struct complex first, struct complex second);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);	ans = add(num1, num2);	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;}struct complex add (struct complex first, struct complex second){	struct complex result;	result.real = first.real + second.real;	result.imag = first.imag + second.imag;	/* Identical result, less typing:		struct complex result = first;		result.real += second.real;		result.imag += second.imag; */	return result;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -