Vous êtes sur la page 1sur 5

//Nombre del Programa: Temperatura Placa Placa::Placa( int Ren, int Col, double Pre )

using namespace std; {


#include <cmath> AsigRen( Ren );
#include <iostream> AsigCol( Col );
AsigPre( Pre );
class Placa AsigMem( Renglon, Columna );
{ private:
}//
int Renglon;
int Columna; Placa::Placa( Placa& RefMat )
double Precision; {
AsigRen( RefMat.Renglon );
double** AptAM; AsigCol( RefMat.Columna );
public: AsigMem( RefMat.Renglon,
Placa( int Ren = 1, int Col = 1, double RefMat.Columna )
Pre = 0.01 ); for( int i = 0; i < ObtRen( ); i++ )
Placa( Placa& RefMat ); for( int j = 0; j < ObtCol( ); j++ )
{
// Funciones set AptAM[i][j] = RefMat.AptAM[i][j];
void AsigRen( int Ren ); }
void AsigCol( int Col );
void AsigPre( double Pre ); }//
// Funciones set
//Funciones get void Placa::AsigRen( int Ren )
int ObtRen( void );
int ObtCol( void ); {
double ObtPre( void ); Renglon = ( Ren < 1 )? 1 : Ren;
}//
//Asignar Memoria void Placa::AsigCol( int Col )
void AsigMem( int Ren, int Col ); {
Columna = ( Col < 1 )? 1 : Col;
void Leer( void );
void Imprimir( void ); }//
void CalTem( void );
void CalTemPla( void ); void Placa::AsigPre( double Pre )
void PromEsqui( int i, int j ,int A ); {
double CalSum (int i); Precision = ( Pre <= 0 ) ? 0.1: Pre;
double AsenDes(int i, int j); }//
}; //Funciones get

int Placa::ObtRen( void )


{ return Renglon;
}//
cout << endl;
}//
int Placa::ObtCol( void )

{
return Columna; void Placa::Imprimir( void )
}//
{
double Placa::ObtPre( void ) for( int i = 0; i < ObtRen( ); i++ )
{ { cout << endl;
return Precision; for ( int j = 0; j < ObtCol( ); j++ )
{
}//
cout << AptAM[i][j] << " ";
//Asignar Memoria }//Fin del for interno
void Placa::AsigMem( int Ren, int Col ) }//Fin del for externo
cout << endl << endl;
{ }//Fin de Imprimir( )
AptAM = new double* [ Ren ];
for( int i = 0; i < ObtRen( ); i++ ) void Placa::CalTem( void )
{
{
double TemVie;
AptAM[i] = new double [ Col ];
bool Bandera = false;
}
for( int d = 0; d < ObtRen( ); d++ )
for( int i = 0; i < ObtRen( ); i++ )
{ for ( int j = 1; j < ObtCol( )-1; j++ )
for ( int j = 0; j < ObtCol( ); j++
{AptAM[d][j] = (AptAM[d][0] +
{ AptAM[i][j] = 0; }
AptAM[d][ObtCol( )-1]) / 2.0;}
}//
}
void Placa::Leer( void )
while( Bandera == false )
{
{
for( int i = 0 ; i < ObtRen( ); i++ )
{ cout << "Dame la Temperatura T1 del for( int i = 0; i < ObtRen( ); i++ )
elemento [ " << i << " ] << "[ 0 ] = ";
cin >> AptAM[i][0]; {
cout << "Dame la Temperatura T2 del for ( int j = 1; j < ObtCol( )-1; j++ )
elemento [ " << i << " ]" << "[ " << ObtCol() - 1
<< " ] = "; {
cin >> AptAM[ i ] [ (ObtCol() - 1) ];
cout << endl;} TemVie = AptAM[i][j];
cout << "Dame la precision = ";
cin >> Precision;
AptAM[ i ][j] = (AptAM[i][j-1] + {
AptAM[i][j] + AptAM[i][j+1]) / 3.0;

AptAM[i][j] = (AptAM[i-1][j-1] +
if( fabs( AptAM[i][j] - TemVie) < AptAM[i-1][j] + AptAM[i-1][j+1] +
Precision )
AptAM[i][j-1] + AptAM[i][j] +
Bandera = true; AptAM[i+1][j+1]+

else AptAM[i+1][j-1] +
AptAM[i+1][j] + AptAM[i+1][j+1]) / 9.0;
Bandera = false;

}//Fin de for interno


}//Fin de for interno
}//Fin de for externo
}//Fin de for externo
}//Fin del while
}//
//return (AptAM[ i ][j])

}//
void Placa::PromEsqui( int i, int j, int A )
void Placa::CalTemPla( void )
{
{
AptAM[i][j] = (AsenDes( i, j) +
int A=0; CalSum(i))/A;
A=ObtRen()+(ObtCol()-1); }//

double Placa::CalSum (int i)


PromEsqui(0,ObtCol()-1,A); { double R=0;
PromEsqui(ObtRen()-1,ObtCol()-1,A); for ( int j = 0; j < ObtCol( ); j++ )
PromEsqui(ObtRen()-1,0,A); R+=AptAM[i][j];
PromEsqui(0,0,A); return R;

for( int i = 1; i < ObtRen( )-1; i++ ) }//


{

for( int j = 1; j < ObtCol( )-1; j++ ) double Placa::AsenDes(int i, int j)


{

double Res; void Leer( int& Ren, int& Col );

if (i==0 && j == (ObtCol( )-1)) int main( void )

{ {

for ( int c=1 ;c < ObtRen( ); c++ )

Res+= AptAM[c][j];

}//fin de if int Ren;

else if(i==0 && j ==0) int Col;

{ char c;

for ( int i=1 ;i < ObtRen( ); i++ )

Res+= AptAM[i][j]; do

} {

else if(i==ObtRen()-1&& j == ObtCol()-1) system( "cls ");

{ Leer( Ren, Col );

for ( int i=0 ;i<ObtRen( )-1; i++ ) Placa M1( Ren, Col );

Res+= AptAM[i][j]; cout << "LECTURA DE LOS DATOS DE LA


PLACA" << endl<<endl;
}
M1.Leer( );
else if(i==ObtRen()-1 && j ==0)
cout.setf( ios::fixed);
{
cout.setf( ios::showpoint);
for ( int i=0 ;i < ObtRen( )-1; i++ )
cout.precision( 0 );
Res+= AptAM[i][j];
cout<<"Datos de la temperatura"<<endl;
}
M1.CalTem();

M1.Imprimir();
return Res;
M1.CalTemPla();
}//
cout<<"Temperatura de la placa"<<endl; try

M1.Imprimir(); {if(Ren<2||Col<2)

throw (1);}
cout<<"DESEA CONTINUAR (S/N):";
catch(int E)
cin>>c;
{cout<<endl<<"Datos incorrectos"<<endl;
c=toupper(c);
system("pause");}

while(c=='S'); } while(Ren<2||Col<2);

system( "pause" ); }

return 0;

}//

void Leer( int& Ren, int& Col )

do

system("cls");

cout<<endl<<"\t\tLectura de Datos:
"<<endl

<<"Los renglones y columnas no


pueden ser menores a 3"<<endl;

cout <<endl<< "Ingrese los renglones: ";

cin >> Ren;

cout << "Ingrese las columnas : ";

cin >> Col;

cout << endl;

Vous aimerez peut-être aussi