R
ruslana
подскажите что не правильно
C++:
#include <vcl.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::Button1Click(TObject *Sender)
{
n=StrToInt(Edit1->Text);
StringGrid1->ColCount=n;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
for(int i=0;i<n;i++)
a[i]=StrToFloat(StringGrid1->Cells[i][0]);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
m=StrToFloat(Edit6->Text);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
long long nth_element(int x, int l,int r,int k, int m);
{
long long x=(a[n-1]+a[0])/2;
int i=0,j=n-1;
while(i<=j)
{
while(a[i] < x) i++;
while(a[j] > x) j--;
if(i<=j)
{
swap(a[i],a[j]);
i++;
j--;
}
}
if(0<=m && m<=j)
return nth_element(,j,m);
if( i<=m && m<=n-1)
return kth(i,n-1,m);
return a[m];
}
Edit2->Text=FloatToStr(a[m]);
}
//---------------------------------------------------------------------------