|
#include <vcl.h>
//#include <math>
//#include <iostream>
#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)
{
int n = StrToInt(strtoint->Text); // 문자열을 정수로 변환
ShowMessage(n);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
int n = StrToIntDef(strtointdef->Text, 0); // 변환 실패 시 기본값 사용
ShowMessage(n);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
double n = StrToFloat(strtofloat->Text); // 문자열을 실수로 변환
ShowMessage(n);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
double n = StrToFloatDef(strtofloatdef->Text, 0.0); // 실수 변환 실패 시 기본값 사용
ShowMessage(n);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
{
String s = IntToHex(255, 4); // 정수를 16진수로 변환
inttohex->Caption = s;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button6Click(TObject *Sender)
{
// 에러가 나는 함수 호출: Call to undefined function
int n = Round(12.7); // 반올림
round->Caption = IntToStr(n);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button7Click(TObject *Sender)
{
// 에러가 나는 함수 호출: Call to undefined function
int n = Trunc(12.7); // 소수점 이하 버림
trunc->Caption = IntToStr(n);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button8Click(TObject *Sender)
{
// 에러가 나는 함수 호출: Call to undefined function
int n = Abs(-10); // 절대값 계산
abs->Caption = IntToStr(n);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button9Click(TObject *Sender)
{
int n = Min(10, 20); // 두 값 중 작은 값
min->Caption = IntToStr(n);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button10Click(TObject *Sender)
{
int n = Max(10, 20);
max->Caption = IntToStr(n); // 두 값 중 큰 값
}
//---------------------------------------------------------------------------
|