c_cpp 复杂

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp 复杂相关的知识,希望对你有一定的参考价值。

#include <bits/stdc++.h>
using namespace std;

class Complex {
public:
    int a,b;
    Complex(){

    }
    void num (int a, int b);
    int modulus (int a, int b);
};
int Complex :: modulus (int a, int b){
    int x = sqrt(a*a + b*b);
    return x;
}
void Complex :: num (int a, int b){
    if (b<0){
        cout<<a<<b<<"i"<<endl;
    }else{
        cout<<a<<"+"<<b<<"i"<<endl;
    }
}


int main (){
    Complex c1, c2;
    c1.num (6,8);
    c2.num (4,-3);
    int mod = c.modulus (4,3);
    cout<<mod<<endl;
    return 0;
}

以上是关于c_cpp 复杂的主要内容,如果未能解决你的问题,请参考以下文章