Documentos de Académico
Documentos de Profesional
Documentos de Cultura
2do Deptal Progra
2do Deptal Progra
#include<iostream>
#include<windows.h>
using namespace std;
struct complejo
{
float r,i;
};
complejo operator + (complejo a, complejo b)
{
complejo TEMP={a.r +b.r , a.i+b.i};
return TEMP;
}
int main()
{
system("title NUMEROS COMPLEJOS");
int a=-8,b=0;
complejo X={1,2};
complejo Y={2,5};
complejo Z;
Z=X+Y;
a=a+b;
cout<<endl<<"RESULTADO = "<<Z.r<<","<<Z.i<<"i"<<endl;
cout<<endl<<a;
_____________________________________________________________________________________
NUMEROS COMPLEJOS
#include<iostream>
#include<windows.h>
using namespace std;
struct complejo
{
float r,i;
};
int main()
{
inicio:
float x1,x2,y1,y2;
int op;
system("cls");
system("title CALCULADORA DE NUMEROS COMPLEJOS");
";
cin>>x1;
cout<<"\t\tNumero Imaginario:
";
cin>>x2;
cout<<"\nX= [ "<<x1<<" , "<<x2<<" i]";
";
cin>>y1;
cout<<"\t\tNumero Imaginario:
";
cin>>y2;
cout<<"\nY= [ "<<y1<<" , "<<y2<<" i]\n\n\t\t";
system("pause");
complejo X={x1,x2};
complejo Y={y1,y2};
complejo Z;
start:
system("cls");
switch(op)
{
case 1:
system("cls");
cout<<"\t\t\t\tSumando...\n\n";
cout<<"X= [ "<<x1<<" , "<<x2<<" i]";
cout<<"\nY= [ "<<y1<<" , "<<y2<<" i]\n\n";
cout<<"\t\t\t\t [X+Y]\n\n";
cout<<"\n\n\t\tCalculando...\n\n";
system("pause");
Z=X+Y;
cout<<endl<<"\n\t\tRESULTADO = [ "<<Z.r<<" ,
"<<Z.i<<" i]"<<endl<<endl;
system("pause");
goto start;
break;
case 2:
system("cls");
cout<<"\t\t\t\tRestando...\n\n";
cout<<"X= [ "<<x1<<" , "<<x2<<" i]";
cout<<"\nY= [ "<<y1<<" , "<<y2<<" i]\n\n";
cout<<"\t\t\t\t [X-Y]\n\n";
cout<<"\t\t\t[ "<<x1<<" , "<<x2<<" i] - [ "<<y1<<" ,
"<<y2<<" i]";
cout<<"\n\n\t\tCalculando...\n\n";
system("pause");
Z=X-Y;
cout<<endl<<"\n\t\tRESULTADO = [ "<<Z.r<<" ,
"<<Z.i<<" i]"<<endl<<endl;
system("pause");
goto start;
break;
case 3:
system("cls");
cout<<"\t\t\t\tMultiplicando...\n\n";
cout<<"X= [ "<<x1<<" , "<<x2<<" i]";
cout<<"\nY= [ "<<y1<<" , "<<y2<<" i]\n\n";
cout<<"\t\t\t\t [X*Y]\n\n";
cout<<"\t\t\t[ "<<x1<<" , "<<x2<<" i] * [ "<<y1<<" ,
"<<y2<<" i]";
cout<<"\n\n\t\tCalculando...\n\n";
system("pause");
Z=X*Y;
cout<<endl<<"\n\t\tRESULTADO = [ "<<Z.r<<" ,
"<<Z.i<<" i]"<<endl<<endl;
system("pause");
goto start;
break;
case 4:
system("cls");
cout<<"\t\t\t\tDividiendo...\n\n";
cout<<"X= [ "<<x1<<" , "<<x2<<" i]";
cout<<"\nY= [ "<<y1<<" , "<<y2<<" i]\n\n";
cout<<"\t\t\t\t [X/Y]\n\n";
cout<<"\t\t\t[ "<<x1<<" , "<<x2<<" i] / [ "<<y1<<" ,
"<<y2<<" i]\n";
cout<<"\n\n\t\tCalculando...\n\n";
system("pause");
Z=X/Y;
cout<<endl<<"\n\t\tRESULTADO = [ "<<Z.r<<" ,
"<<Z.i<<" i]"<<endl<<endl;
system("pause");
goto start;
break;
case 5:
goto inicio;
break;
case 6:
goto exit;
break;
default:
cout<<"\n\n\tCaracter NO Valido, Intentelo de
Nuevo...\n\n\n\n";
system("pause");
goto start;
}
exit:
cout<<"\n\nAdios...\n";
_____________________________________________________________________________________
struct complejo
{
float r,i;
};
int main ()
{
complejo X{50,75};
complejo Y;
cin>>Y;
complejo Z = X + Y ;
cout <<endl;
cout << "\t\tX = " << X <<"\n";
cout << "\t\tY = " << Y <<"\n";
cout << "\t\tZ = " << Z <<"\n\n";
return 0;
}
_____________________________________________________________________________________
struct complejo
{
float r,i;
};
int main()
{
cout <<endl;
cout << "\t\tX = " << X <<"\n";
cout << "\t\tY = " << Y <<"\n";
cout << "\t\tZ = " << Z <<"\n\n";
return 0;
}
_____________________________________________________________________________________
CLASES AMIGAS
#include <iostream>
using namespace std;
class A
{
private:
int a;
public:
A()
{
a=0;cout<<"Constante 1 Creado"<<endl;
}
void Aa()
{
cin>>a;
}
};
class B: public A
{
private:
float b;
public:
B()
{
b=0;cout<<"Objeto 2 Creado";
}
void Ab()
{
cin>>b;
}
};
int main()
{
A ob1; B ob2;
ob1.Aa();
ob2.Aa();
ob2.Ab();
}
_____________________________________________________________________________________
_____________________________________________________________________________________