TrabalhosGratuitos.com - Trabalhos, Monografias, Artigos, Exames, Resumos de livros, Dissertações
Pesquisar

Programa Operações Com Números Complexos Usando Classes

Por:   •  17/8/2020  •  Trabalho acadêmico  •  757 Palavras (4 Páginas)  •  115 Visualizações

Página 1 de 4

#include

#include

#include

using namespace std;

// funcao para setar os valores de real e imaginario

class Complex{

        private:

        double real, imag;

        public:

        Complex(){

        real=imag=0;

                }

                

                ~Complex(){

        //         Liberando a memoria alocada

                }

        // Setando as variaveis

Complex(double r){

        real=r;

        imag=0;

        

}

Complex (double r, double i){

        real=r;

        imag=i;

}

Complex (Complex &obj){

        real=obj.real;

        imag=obj.imag;

}

// funcoes para as operacoes

Complex add(Complex c){

        Complex Add;

        Add.real = real + c.real;

        Add.imag - imag + c.imag;

        return Add;

}

Complex sub(Complex c){

        Complex Sub;

        Sub.real = real - c.real;

        Sub.imag = imag - c.imag;

        return Sub;

}

Complex mult(Complex c) {

        Complex Mult;

        Mult.real = real*c.real - imag*c.imag;

         Mult.imag = real*c.imag - c.real*imag;

  return Mult;

 

}

 Complex div(Complex c){

  Complex Div;

  Div.real = (real*c.real + imag*c.imag)/(c.real*c.real + c.imag*c.imag);

  Div.imag = (imag*c.real + real*c.imag)/(c.real*c.real + c.imag*c.imag);

  return Div;

}

Complex polar(double r, double theta) {

        

}

//

//funcao para imprimir os numeros

void print(){

        cout<

}

double getReal() const{

return real;

}

double getImag() const {

return imag;

}

void setReal (double re){

        real = re;

}

void setImag (double im){

        imag = im;

...

Baixar como (para membros premium)  txt (2.8 Kb)   pdf (24.7 Kb)   docx (7.5 Kb)  
Continuar por mais 3 páginas »
Disponível apenas no TrabalhosGratuitos.com