|
왕초짜 님이 쓰신 글 :
: 답변 감사합니다.
:
: 혹시 strtointdef(edit1.text,0) in [1,2,3,4,5] 에 대응하는것은 없을까요??
그냥
int n = StrToIntDef(Edit1->Text, 0);
일때
if (1 <= n && n <= 5)
또는
if (n == 1 || n == 2 || n == 3 || n == 4 || n == 5)
또는
switch (n) {
case 1: case 2: case 3: case 4: case 5:
...
}
로 하면 되지 않나요?
: 김백일 님이 쓰신 글 :
: : 왕초짜 님이 쓰신 글 :
: : :
: : : -- 델 파 이 --
: : : procedure TForm1.Button1Click(Sender: TObject);
: : : begin
: : : case strtointdef(edit1.text,0) of
: : : 1..10 : showmessage('1~10');
: : : 22,44 : showmessage('22,44');
: : : end;
: : : if strtointdef(edit1.text,0) in [1,2,3,4,5] then
: : : showmessage('1,2,3,4,5');
: : : end;
: : :
: : :
: : : 이 case문과 if문을 C++builder로 전환을 못하겠어요..ㅠㅠ
: : :
: : : 무더운 날씨 모두들 수고하세염
: :
: : 파스칼의 case문에 비해 C의 switch문은 기능이 제한적입니다.
: : 그냥 if문으로 쓰세요.
: :
: : void __fastcall TForm1::Button1Click(TObject* Sender)
: : {
: : int n = StrToIntDef(Edit1->Text, 0);
: :
: : if (1 <= n && n <=10) {
: : ShowMessage("1~10");
: : if (n <= 5)
: : ShowMessage("1,2,3,4,5");
: : } else if (n == 22 || n == 44)
: : ShowMessage("22,44");
: : }
|