zoukankan      html  css  js  c++  java
  • 第五章例5-6

    #include<stdio.h>
    float result_real,result_imag;
    int main(void)
    {
        float imag1,imag2,real1,real2;
        void complex_prod(float real1,float imag1,float real2,float imag2);
        void complex_add(float real1,float imag1,float real2,float imag2);
        printf("Enter 1st complex number(real and imaginary):");
        scanf_s("%f%f",&real1,&imag1);
        printf("Enter 2nd complex number(real and imaginary):");
        scanf_s("%f%f",&real2,&imag2);
        complex_add( real1,imag1,real2,imag2);
        printf("addition of complex is %f+%fi
    ",result_real,result_imag);
        complex_prod(real1,imag1,real2,imag2);
        printf("product of complex is %f+%fi
    ",result_real,result_imag);
    
        return 0;
    }
    void complex_add(float real1,float imag1,float real2,float imag2)
    {
        result_real=real1+real2;
        result_imag=imag1+imag2;
    }
    void complex_prod(float real1,float imag1,float real2,float imag2)
    {
        result_real=real1*real2-imag1*imag2;
        result_imag=real1*imag2+real2*imag1;
    }

  • 相关阅读:
    链表数据-PHP的实现
    关于go的init函数
    socket小计
    很随笔
    go获取当前项目下所有依赖包
    关于synergy的问题
    二叉树的最大路径和
    大数求和
    重载<<运算符第二个参数必须加上const
    表达式求值
  • 原文地址:https://www.cnblogs.com/laurenliu1994/p/3353129.html
Copyright © 2011-2022 走看看