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

📄 ho14_1.c

📁 Software Development in C: A Practical Approach to Programming and Design 软件开发:编程与设计(C))——国外经典教材·计
💻 C
字号:
#include <stdio.h>

struct complex_number
{
	double i,j;
};


int main()
{
	struct complex_number aComplexNumber;
	struct complex_number anotherComplexNumber;
	struct complex_number result;

	printf("\nPlease enter a complex number. Type the\n");
	printf("imaginary part of the number, then press Enter.");
	printf("\nNext, type the real part of the ");
	printf("number.\n");
	printf("Imaginary part: ");
	scanf("%lf",&aComplexNumber.i);
	printf("Real part: ");
	scanf("%lf",&aComplexNumber.j);

	printf("\nPlease enter another complex number. \n");
	printf("Imaginary part: ");
	scanf("%lf",&anotherComplexNumber.i);
	printf("Real part: ");
	scanf("%lf",&anotherComplexNumber.j);

	result.i = aComplexNumber.i + anotherComplexNumber.i;
	result.j = aComplexNumber.j + anotherComplexNumber.j;

	printf("\n");
	printf("  (%lfi + %lfj)\n",
		   aComplexNumber.i,
		   aComplexNumber.j);
	printf("+ (%lfi + %lfj)\n",
		   anotherComplexNumber.i,
		   anotherComplexNumber.j);
	printf("--------------------------\n");
	printf("  (%lfi + %lfj)\n",
		   result.i,
		   result.j);
	printf("\n");

	return (0);
}

⌨️ 快捷键说明

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