yuanyu


私信TA

用户名:yaunyu

访问量:510

签 名:

等  级
排  名 2457
经  验 2205
参赛次数 0
文章发表 5
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

TA的其他文章

解题思路:

123.png

注意事项:

参考代码:

#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>
#include <iomanip>
using namespace std;
typedef struct{
 double a;
 double b;    
}point;  //别名
point add(point x,point y)
{
    point sum;
    sum.a=x.a+y.a;
    sum.b=x.b+y.b;
    return sum;
}
point jianhao(point x,point y)
{
    point sum;
    sum.a=x.a-y.a;
    sum.b=x.b-y.b;
    return sum;
}
point chenghao(point x,point y)
{
    point sum;
    sum.a=x.a*y.a-x.b*y.b;
    sum.b=x.a*y.b+x.b*y.a;
    return sum;
}
point  chuhao(point x,point y)
{
    point sum;
    sum.a=(x.a*y.a+x.b*y.b)*1.0/(pow(y.a,2)+pow(y.b,2));
    sum.b=(x.b*y.a-x.a*y.b)*1.0/(pow(y.a,2)+pow(y.b,2));
    return sum;
}
int main(){
      point x,y,result;  //自定义变量
      char fuhao;
      double a,b,c,d;
      cin>>fuhao>>a>>b>>c>>d;
      x.a=a;
      x.b=b;
      y.a=c;
      y.b=d;
      double s;
      if(fuhao=='+')
      {
          result=add(x,y);
      }
    else if(fuhao=='-')
    result =jianhao(x,y);
    else if(fuhao=='*')
    result=chenghao(x,y);
    else if(fuhao=='/')
    result =chuhao(x,y);
    cout<<fixed<<setprecision(2)<<result.a<<"+"<<result.b<<"i";
    cout<<endl;
    return 0;
}

 

0.0分

2 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区