U mnie problemów nie ma żadnych, tylko na innym kompie z rad studio przypominam...
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "dodawanie_wezla.h"
#include "alebania.cpp"
#include "BigIntegerLibrary.h"
#include "interpolacja.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
BigInteger Potega(BigInteger x, BigInteger y)
{
BigInteger wynik=1;
if (y!=0) for(BigInteger i=0;i<y;i=i+1) wynik=wynik*x;
return(wynik);
}
BigInteger liczNWD (BigInteger a, BigInteger b)
{
BigInteger c;
while (b != 0)
{
c = a % b;
a = b;
b = c;
}
return(a);
}
void zwykly(bool a)
{
Form2->Edit1->Visible=a;Form2->Label1->Visible=a;
Form2->Edit2->Visible=a;Form2->Label2->Visible=a;
Form2->Edit3->Visible=a;Form2->Label3->Visible=a;
Form2->Edit4->Visible=a;Form2->Label4->Visible=a;
}
void dziesietny (bool a)
{
Form2->Edit5->Visible=a;Form2->Label5->Visible=a;
Form2->Edit6->Visible=a;Form2->Label6->Visible=a;
}
void doGrida(void)
{
if ( (Form1->StringGrid1->ColCount==2) && (Form1->StringGrid1->Cells[1][0]=="") ) {}
else Form1->StringGrid1->ColCount=Form1->StringGrid1->ColCount+1;
int width=Form2->Test1->Width;
if (Form2->Test2->Width > width) width=Form2->Test2->Width;
if (Form2->Test3->Width > width) width=Form2->Test3->Width;
if (Form2->Test4->Width > width) width=Form2->Test4->Width;
Form1->StringGrid1->Cells[Form1->StringGrid1->ColCount - 1][0] = Form2->Test1->Caption;
Form1->StringGrid1->Cells[Form1->StringGrid1->ColCount - 1][1] = Form2->Test2->Caption;
Form1->StringGrid1->Cells[Form1->StringGrid1->ColCount - 1][2] = Form2->Test3->Caption;
Form1->StringGrid1->Cells[Form1->StringGrid1->ColCount - 1][3] = Form2->Test4->Caption;
Form1->StringGrid1->ColWidths[Form1->StringGrid1->ColCount - 1] = width + 3;
}
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm2::FormShow(TObject *Sender)
{
Form2->Edit1->Text="";Form2->Edit2->Text="";
Form2->Edit3->Text="";Form2->Edit4->Text="";
Form2->Edit5->Text="";Form2->Edit6->Text="";
if (Form2->RadioButton2->Checked==true)
{
dziesietny(true);
zwykly(false);
}
else
{
dziesietny(false);
zwykly(true);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::RadioButton2Click(TObject *Sender)
{
dziesietny(true);
zwykly(false);
}
//---------------------------------------------------------------------------
void __fastcall TForm2::RadioButton1Click(TObject *Sender)
{
dziesietny(false);
zwykly(true);
}
//---------------------------------------------------------------------------
void __fastcall TForm2::DodajClick(TObject *Sender)
{
DecimalSeparator = '.';
Application->UpdateFormatSettings = false ;
if (Form2->RadioButton2->Checked==true)
{
if ( (Form2->Edit5->Text=="") || (Form2->Edit6->Text=="") )
{
ShowMessage("Nie wszystkie pola zostały wypełnione.");
}
else
{
try
{
double a,b;
a=StrToFloat(Edit5->Text);
b=StrToFloat(Edit6->Text);
if (Edit5->Text.Pos(".") == 0)
{
Test1->Caption=Edit5->Text;
Test2->Caption=1;
}
else
{
BigInteger y;
y=Potega(10, Form2->Edit5->Text.Length() - Form2->Edit5->Text.Pos("."));
std::string s1=bigIntegerToString(y);
Test2->Caption=s1.c_str();
Test1->Caption=StringReplace(Edit5->Text,".","",TReplaceFlags());
}
if (Edit6->Text.Pos(".") == 0)
{
Test3->Caption=Edit6->Text;
Test4->Caption=1;
}
else
{
BigInteger y;
y=Potega(10, Form2->Edit6->Text.Length() - Form2->Edit6->Text.Pos("."));
std::string s1=bigIntegerToString(y);
Test4->Caption=s1.c_str();
Test3->Caption=StringReplace(Edit6->Text,".","",TReplaceFlags());
}
BigInteger a1,b1,c1,d1,NWD;
AnsiString help;
std::string s2;
help = Test1->Caption;
s2 = help.c_str();
a1=stringToBigInteger(s2);
help = Test2->Caption;
s2 = help.c_str();
b1=stringToBigInteger(s2);
help = Test3->Caption;
s2 = help.c_str();
c1=stringToBigInteger(s2);
help = Test4->Caption;
s2 = help.c_str();
d1=stringToBigInteger(s2);
NWD=liczNWD(a1,b1);
a1=a1/NWD;b1=b1/NWD;
NWD=liczNWD(c1,d1);
c1=c1/NWD;d1=d1/NWD;
s2=bigIntegerToString(a1);
Test1->Caption=s2.c_str();
s2=bigIntegerToString(b1);
Test2->Caption=s2.c_str();
s2=bigIntegerToString(c1);
Test3->Caption=s2.c_str();
s2=bigIntegerToString(d1);
Test4->Caption=s2.c_str();
doGrida();
Form2->Edit1->Text="";Form2->Edit2->Text="";
Form2->Edit3->Text="";Form2->Edit4->Text="";
Form2->Edit5->Text="";Form2->Edit6->Text="";
}
catch(...)
{
ShowMessage("Nie wszystkie pola zostały wypełnione poprawnie.");
}
}
}
else
{
if ( (Form2->Edit1->Text=="") || (Form2->Edit2->Text=="") || (Form2->Edit3->Text=="") || (Form2->Edit4->Text=="") )
{
ShowMessage("Nie wszystkie pola zostały wypełnione.");
}
else
{
try
{
BigInteger a1,b1,c1,d1,NWD;
AnsiString help;
std::string s2;
help = Edit1->Text;
s2 = help.c_str();
a1=stringToBigInteger(s2);
help = Edit2->Text;
s2 = help.c_str();
b1=stringToBigInteger(s2);
help = Edit3->Text;
s2 = help.c_str();
c1=stringToBigInteger(s2);
help = Edit4->Text;
s2 = help.c_str();
d1=stringToBigInteger(s2);
NWD=liczNWD(a1,b1);
a1=a1/NWD;b1=b1/NWD;
NWD=liczNWD(c1,d1);
c1=c1/NWD;d1=d1/NWD;
s2=bigIntegerToString(a1);
Test1->Caption=s2.c_str();
s2=bigIntegerToString(b1);
Test2->Caption=s2.c_str();
s2=bigIntegerToString(c1);
Test3->Caption=s2.c_str();
s2=bigIntegerToString(d1);
Test4->Caption=s2.c_str();
doGrida();
Form2->Edit1->Text="";Form2->Edit2->Text="";
Form2->Edit3->Text="";Form2->Edit4->Text="";
Form2->Edit5->Text="";Form2->Edit6->Text="";
}
catch(...)
{
ShowMessage("Nie wszystkie pola zostały wypełnione poprawnie.");
}
}
}
}
//---------------------------------------------------------------------------