Turbo-C
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
터보-C 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
Lua 게시판
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C/C++ Q/A
[847] Re:1에서 100까지 구하는 code 부탁!!!
박재욱.사탕 [withsun] 1903 읽음    2002-07-10 01:35
C++ Builder로 만들어 봤습니다.

<dfm 파일>
object Form1: TForm1
  Left = 442
  Top = 233
  Width = 247
  Height = 190
  Caption = '100 까지 합구하기'
  Color = clBtnFace
  Constraints.MaxHeight = 190
  Constraints.MaxWidth = 247
  Constraints.MinHeight = 190
  Constraints.MinWidth = 247
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 10
    Top = 10
    Width = 131
    Height = 13
    AutoSize = False
    Caption = '현재 더해질려는 숫자'
  end
  object Label2: TLabel
    Left = 10
    Top = 40
    Width = 131
    Height = 13
    AutoSize = False
    Caption = '지금까지의 합'
  end
  object Bevel1: TBevel
    Left = 5
    Top = 60
    Width = 226
    Height = 6
    Shape = bsBottomLine
  end
  object Label3: TLabel
    Left = 10
    Top = 75
    Width = 131
    Height = 13
    AutoSize = False
    Caption = '결 과'
  end
  object Bevel2: TBevel
    Left = 0
    Top = 5
    Width = 236
    Height = 101
  end
  object CGauge1: TCGauge
    Left = 0
    Top = 110
    Width = 236
    Height = 21
  end
  object StaticText1: TStaticText
    Left = 150
    Top = 7
    Width = 71
    Height = 19
    AutoSize = False
    TabOrder = 0
  end
  object StaticText2: TStaticText
    Left = 150
    Top = 37
    Width = 71
    Height = 19
    AutoSize = False
    TabOrder = 1
  end
  object StaticText3: TStaticText
    Left = 150
    Top = 72
    Width = 71
    Height = 19
    AutoSize = False
    TabOrder = 2
  end
  object Button1: TButton
    Left = 0
    Top = 135
    Width = 236
    Height = 25
    Caption = '100까지의 합을 구해봅시다.'
    TabOrder = 3
    OnClick = Button1Click
  end
  object Timer1: TTimer
    Enabled = False
    Interval = 500
    OnTimer = Timer1Timer
    Left = 195
    Top = 25
  end
end

<헤드 파일>
//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "CGAUGES.h"
#include <ExtCtrls.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:    // IDE-managed Components
        TTimer *Timer1;
        TLabel *Label1;
        TStaticText *StaticText1;
        TLabel *Label2;
        TStaticText *StaticText2;
        TBevel *Bevel1;
        TLabel *Label3;
        TStaticText *StaticText3;
        TBevel *Bevel2;
        TCGauge *CGauge1;
        TButton *Button1;
        void __fastcall Button1Click(TObject *Sender);
        void __fastcall Timer1Timer(TObject *Sender);
private:    // User declarations
        int nCount;
        int nResult;
public:        // User declarations
        __fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif

<cpp 파일>
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "CGAUGES"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
        nCount = 0;
        nResult = 0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
        Timer1->Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
        if(nCount <= 100){
                nResult += nCount;
                CGauge1->Progress = nCount;
                StaticText1->Caption = IntToStr(nCount);
                StaticText2->Caption = IntToStr(nResult);
                nCount++;
        }
        StaticText3->Caption = IntToStr(nResult);
}
//---------------------------------------------------------------------------

+ -

관련 글 리스트
848 1에서 100까지 구하는 code 부탁!!! 초부 1924 2002/07/09
853     Re:1에서 100까지 출력~ (포트란 버젼~) 시간한줌 1917 2002/07/10
893         [잡담2]포트란 무시해서 죄송합니다. -_-;; 김백일 2064 2002/07/18
854         [잡담]아, 포트란은 무시하고파~ ^^; 김백일 2161 2002/07/10
847     Re:1에서 100까지 구하는 code 부탁!!! 박재욱.사탕 1903 2002/07/10
846     원하시는분이 프로그램을 다루시는 분 맞나염?? 정성훈.해미 1774 2002/07/09
845     Re:1에서 100까지 구하는 code 부탁!!! @@ 1772 2002/07/09
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.