C ++程序执行复数乘法
复数是表示为a+bi的数字,其中i是虚数,而a和b是实数。一些关于复数的例子是-
2+3i 5+9i 4+2i
一个执行复数乘法的程序如下-
示例
#include<iostream>
using namespace std;
int main(){
int x1, y1, x2, y2, x3, y3;
cout<<"Enter the first complex number : "<<endl;
cin>> x1 >> y1;
cout<<"\nEnter second complex number : "<<endl;
cin>> x2 >> y2;
x3 = x1 * x2 - y1 * y2;
y3 = x1 * y2 + y1 * x2;
cout<<"The value after multiplication is: "<<x3<<" + "<<y3<<" i ";
return 0;
}输出结果
上面程序的输出如下
Enter the first complex number : 2 1 Enter second complex number : 3 4 The value after multiplication is: 2 + 11 i
在上述程序中,用户输入了两个复数。这给出如下-
cout<<"Enter the first complex number : "<<endl; cin>> x1 >> y1; cout<<"\nEnter second complex number : "<<endl; cin>> x2 >> y2;
这两个复数的乘积可通过所需公式找到。这给出如下-
x3 = x1 * x2 - y1 * y2; y3 = x1 * y2 + y1 * x2;
最后,显示产品。这在下面给出-
cout<<"The value after multiplication is: "<<x3<<" + "<<y3<<" i ";
热门推荐
1 训练狗狗工作
4 狗狗定点排便训练
5 狗狗训练吠叫
6 狗狗尿垫训练
7 狗狗训练座
8 狗狗训练攻略
9 狗狗训练记
10 做训练狗狗
11 狗狗训练词
12 狗狗谢谢怎么训练
13 狗狗训练如厕
14 狗狗太凶怎么训练
15 狗狗训练它
16 狗狗克制训练
17 训练基地狗狗
18 怎么样训练狗狗大小硬