Ver Mensaje Individual
  #7  
Antiguo 18-07-2006
Avatar de noe
noe noe is offline
Miembro
 
Registrado: dic 2003
Ubicación: Mexico
Posts: 111
Reputación: 21
noe Va por buen camino
Gracias por contestar.

pero en donde pongo

float f(float x)
{ return pow(x,4);
}

ya que me manda error.....


Mira lo puse asi:


//---------------------------------------------------------------------------

#include <vcl.h>
#include <math.h>

#pragma hdrstop

#include "Unit1.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;



//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------


void __fastcall TForm1::Btn_CalcularClick(TObject *Sender)

{

int n,i;
float a,b,h,s,s2,s4,x,ts2,ts4,s13,suma;
char opc;

float f(float x);
{
return pow(x,4);
}



a=b=h=s=x=s13=suma=0;
a=StrToFloat(Edt_a->Text);
b=StrToFloat(Edt_b->Text);
n=StrToFloat(Edt_Numero->Text);
do
{
if(n%2 !=0)
ShowMessage("el numero debe ser un numero par");
}while(n%2 !=0);

h=(b-a)/n;
s=f(a)+f(b);


Edt_Fa->Text=FloatToStr(f(a));
Edt_Fb->Text=FloatToStr(f(b));
Edt_h->Text=h;
Edt_s->Text=s;
Edt_x->Text=x;



/****************************SIMPSON 1/3**********************************/

//se evaluan los valor de x donde x=x+h en el intervalo (a,b)


x=a+h;

for(int i=1; i<=n-2; i++)
{
f(x);
x+=h;
}


//segun el metodo simpson 1/3 algunos valores seran 2*f(x) o 4*f(x)
x=a+h;

for(i=1; i<=n-1; i++)
{
if(i%2 == 0) //2*f(x)
{
s2=2*f(x);

ts2+=s2;
}
else //4*f(x)
{
s4=4*f(x);

ts4+=s4;
}
x+=h;
}//for
suma = (f(a)+f(b))+(ts2+ts4);
s13=(suma*h)/3;
/*************************************************************************/


Edt_Suma->Text=FloatToStr(suma);
Edt_S13->Text=FloatToStr(s13);



}

//---------------------------------------------------------------------------



Y me manda el siguiente error:

[C++ Error] Unit1.cpp(35): E2467 '_fastcall TForm1::Btn_CalcularClick(TObject *)' cannot return a value

[C++ Warning] Unit1.cpp(39): W8066 Unreachable code
Responder Con Cita