Q&A

  • 아날로그 시계 작성
전 대1 학생입니다 .

교수님이 아래와같은 레포트를 내주셔서 고민하다

이렇게 질문 드립니다 꼭 좀 가르쳐 주세요....

아날로그 시계작성법좀 가르쳐 주세요

또한가지 윈도우에 내장된 계산기 프로그램을 모방하여(+,-,*,/)

연산만 수행하는 프로그램작성법도 가르쳐 주세요

3  COMMENTS
  • Profile
    모승열 1999.05.25 00:30
    심인애 wrote:

    > 전 대1 학생입니다 .

    > 교수님이 아래와같은 레포트를 내주셔서 고민하다

    > 이렇게 질문 드립니다 꼭 좀 가르쳐 주세요....

    > 아날로그 시계작성법좀 가르쳐 주세요

    > 또한가지 윈도우에 내장된 계산기 프로그램을 모방하여(+,-,*,/)

    > 연산만 수행하는 프로그램작성법도 가르쳐 주세요



    소스입니다.

    도움이 되시길...

    PK

  • Profile
    김경수 1999.05.25 07:25
    안녕하세요.

    스택을 이용해 작성한 단순 무식하게 짠 진짜 간단한 계산기입니다.

    그냥 참고로 보시라구요. 도움이 될랑가는 모르겠지만.

    그럼 안녕히..





    모승열 wrote:

    > 심인애 wrote:

    > > 전 대1 학생입니다 .

    > > 교수님이 아래와같은 레포트를 내주셔서 고민하다

    > > 이렇게 질문 드립니다 꼭 좀 가르쳐 주세요....

    > > 아날로그 시계작성법좀 가르쳐 주세요

    > > 또한가지 윈도우에 내장된 계산기 프로그램을 모방하여(+,-,*,/)

    > > 연산만 수행하는 프로그램작성법도 가르쳐 주세요

    >

    > 소스입니다.

    > 도움이 되시길...

    > PK





    PK

  • Profile
    김경수 1999.05.25 10:42
    안녕하세요. 화일이 업로드가 안되는것 같네요..

    그냥 복사해서 드립니다.초보라서..히



    unit u_stack;



    interface



    uses

    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

    StdCtrls, Buttons, ComCtrls, RxGrdCpt, ExtCtrls, RXSplit, RXCtrls,

    MrgMngr, DataConv;



    const maxsize = 10;



    type

    tstack = class //클래스 선언

    stackarray : array[1..maxsize] of string;

    top : integer;

    bottom : integer;

    procedure initialise;

    function isp(i_isp : string): integer; //스택에 있는 연산자 우선순위 반납

    // function icp(i_icp : string): integer; //새로 들어오는 연산자 우선 순위 반납

    function empty : boolean; //스택이 비어있는지 확인

    function full : boolean; //스택이 full인지 확인

    procedure push(p_input : string); //스택에서 추가

    procedure pop(p_delete : string); //스택에서 삭제

    procedure postfix(fix : string); //후위수식 변환 프로시져

    function get_token( input : char): string; //토큰 받아오기

    procedure exe(stack : string); //후위수식 계산

    end;



    type

    TForm1 = class(TForm)

    GroupBox1: TGroupBox;

    GroupBox2: TGroupBox;

    SpeedButton1: TSpeedButton;

    SpeedButton2: TSpeedButton;

    SpeedButton3: TSpeedButton;

    SpeedButton4: TSpeedButton;

    SpeedButton5: TSpeedButton;

    SpeedButton6: TSpeedButton;

    SpeedButton7: TSpeedButton;

    SpeedButton8: TSpeedButton;

    SpeedButton9: TSpeedButton;

    SpeedButton10: TSpeedButton;

    SpeedButton11: TSpeedButton;

    SpeedButton12: TSpeedButton;

    SpeedButton13: TSpeedButton;

    SpeedButton14: TSpeedButton;

    BitBtn1: TBitBtn;

    GroupBox3: TGroupBox;

    Label1: TLabel;

    RxGradientCaption1: TRxGradientCaption;

    sb_1: TStatusBar;

    BitBtn2: TBitBtn;

    Label2: TLabel;

    SpeedButton16: TSpeedButton;

    SpeedButton17: TSpeedButton;

    RxSplitter1: TRxSplitter;

    input: TEdit;

    output: TEdit;

    GroupBox4: TGroupBox;

    MergeManager1: TMergeManager;

    BitBtn3: TBitBtn;

    Label3: TLabel;

    cal: TEdit;

    Label4: TLabel;

    s3: TButton;

    s4: TButton;

    s5: TButton;

    s6: TButton;

    s7: TButton;

    s8: TButton;

    s9: TButton;

    s2: TButton;

    s1: TButton;

    s10: TButton;

    Button1: TButton;

    Button2: TButton;

    procedure FormCreate(Sender: TObject);

    procedure BitBtn2Click(Sender: TObject);

    procedure FormClose(Sender: TObject; var Action: TCloseAction);

    procedure SpeedButton1Click(Sender: TObject);

    procedure BitBtn1Click(Sender: TObject);

    procedure SpeedButton2Click(Sender: TObject);

    procedure SpeedButton3Click(Sender: TObject);

    procedure SpeedButton5Click(Sender: TObject);

    procedure SpeedButton4Click(Sender: TObject);

    procedure SpeedButton6Click(Sender: TObject);

    procedure SpeedButton7Click(Sender: TObject);

    procedure SpeedButton8Click(Sender: TObject);

    procedure SpeedButton9Click(Sender: TObject);

    procedure SpeedButton17Click(Sender: TObject);

    procedure SpeedButton11Click(Sender: TObject);

    procedure SpeedButton14Click(Sender: TObject);

    procedure SpeedButton13Click(Sender: TObject);

    procedure SpeedButton16Click(Sender: TObject);

    procedure SpeedButton12Click(Sender: TObject);

    procedure SpeedButton10Click(Sender: TObject);

    procedure Button1Click(Sender: TObject);

    procedure Button2Click(Sender: TObject);

    procedure BitBtn3Click(Sender: TObject);

    private

    { Private declarations }

    public

    { Public declarations }

    end;



    var

    Form1: TForm1;

    input_c : string;

    mystack : tstack;



    implementation



    {$R *.DFM}

    //휘위 표기식에서 계산하기

    procedure tstack.exe ( stack : string);

    var

    i : integer;

    now : string;

    begin

    stack := stack+'$';

    i := 1;



    repeat



    //일반문자인 경우 스택에 그냥 넘

    if (mystack.get_token(stack[i])='operand') then

    begin

    messagedlg('다음으로..',mtinformation,[mbok],0);

    mystack.push(stack[i]);

    end;



    // + 연산자인경우

    if get_token(stack[i]) = '+' then

    begin

    now := (floattostr(strtofloat(stackarray[top-1])+strtofloat(stackarray[top])));

    messagedlg('다음으로..',mtinformation,[mbok],0);



    mystack.pop(stackarray[top]);

    mystack.pop(stackarray[top]);

    push(now);

    end;



    // - 연산자인경우

    if get_token(stack[i]) = '-' then

    begin

    now := (floattostr(strtofloat(stackarray[top-1])-strtofloat(stackarray[top])));

    messagedlg('다음으로..',mtinformation,[mbok],0);

    mystack.pop(stackarray[top]);

    mystack.pop(stackarray[top]);

    push(now);

    end;



    // * 연산자인경우

    if get_token(stack[i]) = '*' then

    begin

    now := (floattostr(strtofloat(stackarray[top-1])*strtofloat(stackarray[top])));

    messagedlg('다음으로..',mtinformation,[mbok],0);

    mystack.pop(stackarray[top]);

    mystack.pop(stackarray[top]);

    push(now);

    end;



    // / 연산자인경우

    if get_token(stack[i]) = '/' then

    begin

    now := copy(floattostr(strtofloat(stackarray[top-1])/strtofloat(stackarray[top])),0,4);

    messagedlg('다음으로..',mtinformation,[mbok],0);

    mystack.pop(stackarray[top]);

    mystack.pop(stackarray[top]);

    push(now);

    end;

    inc(i);

    until stack[i]='$';

    end;



    //후위 표기식으로 바꾸기

    procedure tstack.postfix(fix : string);

    var

    i,j : integer;

    begin

    fix := fix + '$';

    mystack.push('#');

    i := 1;

    repeat

    //피연산자인경우 그냥 출력

    if (mystack.get_token(fix[i])='operand') then

    begin

    form1.output.text := form1.output.text + fix[i];

    end;



    if get_token(fix[i])='(' then

    begin

    mystack.push(fix[i]);

    end;



    //오른쪽 가로가 나온경우

    if get_token(fix[i])=')' then

    begin

    while (stackarray[top] <> '(') do

    begin

    form1.output.text := form1.output.text + stackarray[top];

    mystack.pop(stackarray[top]);

    end;

    mystack.pop(stackarray[top]);

    end;



    // 연산자인경우

    if ((get_token(fix[i])='+') or (get_token(fix[i])='-') or (get_token(fix[i])='*') or(get_token(fix[i])='/')) then // or(get_token(fix[i])='(')) then

    begin

    if isp(stackarray[top]) >= isp(fix[i]) then

    begin

    form1.output.text := form1.output.text + mystack.stackarray[top];

    mystack.pop(fix[i]);

    mystack.push(fix[i]);

    end

    else

    begin

    mystack.push(fix[i]);

    end;

    end;

    inc(i);

    until fix[i]='$';



    while stackarray[top] <> '#' do

    begin

    form1.output.text := form1.output.text + stackarray[top];

    mystack.pop(stackarray[top]);

    end;

    mystack.pop(stackarray[top]);

    end;







    function tstack.isp(i_isp : string) : integer; //스택에 있는 연산자 우선순위 반납

    var

    temp : char;

    begin

    temp := i_isp[1];

    case temp of

    '+' : result := 2;

    '-' : result := 2;

    '*' : result := 3;

    '/' : result := 3;

    '(' : result := 1;

    ')' : result := 1;

    '$' : result := 0;

    '#' : result := 0;

    end;

    end;

    {

    function tstack.icp(i_icp : string): integer; //새로 들어오는 연산자 우선 순위 반납

    var

    temp : char;

    begin

    temp := i_icp[1];

    case temp of

    '+' : result := 2;

    '-' : result := 2;

    '*' : result := 3;

    '/' : result := 3;

    '(' : result := 0;

    ')' : result := 1;

    '$' : result := 0;

    '#' : result := 0;

    end;

    end;

    }

    //입력 문자열로부터 토큰을 생성하는 함수

    function tstack.get_token( input : char ): string;

    begin

    case input of

    '+' : Result := '+';

    '-' : Result := '-';

    '*' : Result := '*';

    '/' : Result := '/';

    '(' : Result := '(';

    ')' : Result := ')';

    else

    Result := 'operand';

    end;

    end;



    procedure TForm1.FormCreate(Sender: TObject);

    begin

    mystack := tstack.create; //클래스 생성

    mystack.initialise;

    end;



    function tstack.empty : boolean;

    begin

    if top = bottom then

    empty := true

    else

    empty := false;

    end;



    function tstack.full : boolean;

    begin

    if top = maxsize then

    full := true

    else

    full := false;

    end;





    //자료를 입력

    procedure tstack.push(p_input : string);

    begin

    if full then

    messagedlg('스택이 가득찼습니다. 스택을 지운후 다시 입력하십시요!', mterror, [mbok],0)

    else

    begin

    top := top+1;

    stackarray[top] := p_input; //스택에 추가



    //스택그림 보이기

    if form1.FindComponent( 's' + IntToStr(top) ) is Tbutton then

    begin

    Tbutton(form1.FindComponent( 's' + IntToStr(top) )).visible := true;

    Tbutton(form1.FindComponent( 's' + IntToStr(top) )).caption := stackarray[top];

    end;

    end; //if





    end; //push



    procedure tstack.pop(p_delete : string);

    begin

    if empty then

    messagedlg('입력된 값이 없습니다.',mterror,[mbok],0)

    else

    begin

    //버튼들 안보이게 하기

    if form1.FindComponent( 's' + IntToStr(top) ) is Tbutton then

    begin

    Tbutton(form1.FindComponent( 's' + IntToStr(top) )).visible := false;

    Tbutton(form1.FindComponent( 's' + IntToStr(top) )).caption := stackarray[top];

    end;

    p_delete := stackarray[top];

    top := top -1;

    end;



    end;





    // stack 포인터 초기화

    procedure tstack.initialise;

    begin

    top := 0;

    bottom := 0;

    end;





    procedure TForm1.BitBtn2Click(Sender: TObject);

    begin

    close;

    end;



    procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);

    begin

    mystack.Free; //클래스 해제

    action := cafree; //폼 해제

    end;



    procedure TForm1.SpeedButton1Click(Sender: TObject);

    begin

    input_c := input_c + '1';

    input.text := input_c;

    end;





    procedure TForm1.BitBtn1Click(Sender: TObject);

    begin

    //초기화부분

    input_c := ''; //전역변수 초기화

    input.text := ''; //전위표기식 초기화

    output.text := ''; //후위표기식 초기화

    cal.text := '';

    if mystack.empty = false then //스택이 비워졌을때까지 pop

    mystack.pop('pop');

    end;



    procedure TForm1.SpeedButton2Click(Sender: TObject);

    begin

    input_c := input_c + '2';

    input.text := input_c;

    end;



    procedure TForm1.SpeedButton3Click(Sender: TObject);

    begin

    input_c := input_c + '3';

    input.text := input_c;

    end;



    procedure TForm1.SpeedButton5Click(Sender: TObject);

    begin

    input_c := input_c + '4';

    input.text := input_c;

    end;



    procedure TForm1.SpeedButton4Click(Sender: TObject);

    begin

    input_c := input_c + '5';

    input.text := input_c;

    end;



    procedure TForm1.SpeedButton6Click(Sender: TObject);

    begin

    input_c := input_c + '6';

    input.text := input_c;

    end;



    procedure TForm1.SpeedButton7Click(Sender: TObject);

    begin

    input_c := input_c + '7';

    input.text := input_c;

    end;



    procedure TForm1.SpeedButton8Click(Sender: TObject);

    begin

    input_c := input_c + '8';

    input.text := input_c;

    end;



    procedure TForm1.SpeedButton9Click(Sender: TObject);

    begin

    input_c := input_c + '9';

    input.text := input_c;

    end;



    procedure TForm1.SpeedButton17Click(Sender: TObject);

    begin

    input_c := input_c + '(';

    input.text := input_c;

    end;



    procedure TForm1.SpeedButton11Click(Sender: TObject);

    begin

    input_c := input_c + '0';

    input.text := input_c;

    end;



    procedure TForm1.SpeedButton14Click(Sender: TObject);

    begin

    input_c := input_c + ')';

    input.text := input_c;

    end;



    procedure TForm1.SpeedButton13Click(Sender: TObject);

    begin

    input_c := input_c + '*';

    input.text := input_c;

    end;



    procedure TForm1.SpeedButton16Click(Sender: TObject);

    begin

    input_c := input_c + '/';

    input.text := input_c;

    end;



    procedure TForm1.SpeedButton12Click(Sender: TObject);

    begin

    input_c := input_c + '+';

    input.text := input_c;

    end;



    procedure TForm1.SpeedButton10Click(Sender: TObject);

    begin

    input_c := input_c + '-';

    input.text := input_c;

    end;



    procedure TForm1.Button1Click(Sender: TObject);

    begin

    mystack.push('push');

    end;



    procedure TForm1.Button2Click(Sender: TObject);

    begin

    mystack.pop('push');

    end;



    procedure TForm1.BitBtn3Click(Sender: TObject);

    begin

    mystack.postfix(input.text);

    mystack.exe(output.text);

    cal.text := mystack.stackarray[mystack.top];

    end;



    end.



    김경수 wrote:

    > 안녕하세요.

    > 스택을 이용해 작성한 단순 무식하게 짠 진짜 간단한 계산기입니다.

    > 그냥 참고로 보시라구요. 도움이 될랑가는 모르겠지만.

    > 그럼 안녕히..





    • 이상석
    • 1999.05.25 00:57
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 모승열
      1999.05.25 01:26
      이상석 wrote: > 안녕하세요 이상석입니다. > 다름이 아니오라 델파이 4에서 DateTimePicker 에서 날짜만...
    • 지니
    • 1999.05.25 00:36
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 이정욱
      1999.05.25 02:48
      아래 답변에 SendData 프로시져입니다 라는것이 있습니다. 그것을 참고하세요. 여기서 SendData라는 키워...
    • 영인
    • 1999.05.25 00:35
    • 2 COMMENTS
    • /
    • 0 LIKES
    • 신인재
      1999.05.25 01:53
      type tmynum=set of [1..20]; 문장 에러가 나는 군요.. 저도 잘쓰지 않아서 헬프를 참고 했는데 아래...
    • 신인재
      1999.05.25 02:12
      type tmynum= set of 1..90; var mynum:tmynum; aa : Boolean; begin mynum:=[1,2,3,4,10,20...
    • 왕초
    • 1999.05.25 00:32
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 안치봉
      1999.05.25 03:57
      왕초 wrote: > DLL 사용시에 변수 사용 질문입니다.. > 정적 DLL를 사용하고 있고요.. > DLL 안의 함수...
    • sunhee
    • 1999.05.25 00:28
    • 1 COMMENTS
    • /
    • 0 LIKES
    • KJW
      1999.06.04 06:59
      sunhee 께서 말씀하시기를... > 안녕하세요. 선희덕이라고 합니다. > > A라는 프로그램에서 B라는 프...
    • 고부성
    • 1999.05.25 00:17
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 이정욱
      1999.05.25 03:02
      함수인자로 사용하세요. 만약 계산식이 더하는것이라면... function Add(a,b ; integer) : integer; 이...
    • 이정욱
      1999.05.25 03:03
      쩝.. RxLib를 사용하세요. 그안에 RichEdit2 용 컴포넌트가 있습니다. 전진우 wrote: > TRichEdit...
    • 임태영
    • 1999.05.24 23:33
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 모승열
      1999.05.25 00:36
      임태영 wrote: > 안녕하세요,,, 임태영입니다. > > 서버에 있는 테이블을 사용하려고 할 때 User name...
    • 심인애
    • 1999.05.24 23:32
    • 3 COMMENTS
    • /
    • 0 LIKES
    • 모승열
      1999.05.25 00:30
      심인애 wrote: > 전 대1 학생입니다 . > 교수님이 아래와같은 레포트를 내주셔서 고민하다 > 이렇게 ...
    • 김경수
      1999.05.25 07:25
      안녕하세요. 스택을 이용해 작성한 단순 무식하게 짠 진짜 간단한 계산기입니다. 그냥 참고로 보시라구...
    • 김경수
      1999.05.25 10:42
      안녕하세요. 화일이 업로드가 안되는것 같네요.. 그냥 복사해서 드립니다.초보라서..히 unit u_stack; ...
    • 우민석
    • 1999.05.24 23:31
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 변대섭
      1999.05.25 00:39
      우민석 wrote: > 제가 짜는 프로그램은 DBGrid을 이용하여 한 레코드 단위로 바로 바로 데이터 베이스을 A...
    • 박용근
    • 1999.05.24 22:49
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 이정욱
      1999.05.25 00:20
      꼭 필요한것은 아닙니다. 공개된 시리얼 통신 컴포넌트를 사용하셔도 됩니다. 그런데 만약 ZModem같은 파...
    • 김병태
    • 1999.05.24 22:15
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 이정욱
      1999.05.25 00:21
      이미 패치가 되어져 있는것으로 되어있습니다. 즉 해결이 되었다고 하더군요. 또 퀵리포트 정품을 사용하...
    • 고부성
    • 1999.05.24 21:25
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 이정욱
      1999.05.25 03:16
      Edit46안에 숫자가 아닌다른문자를 쓰신것 같네요. 숫자만 변환이 가능해집니다. AccessViolation은 아...
    • 이기남
    • 1999.05.24 20:31
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 이정욱
      1999.05.25 01:27
      모든DB파일이 같은디렉토리안에 있다면 특별히 알리아스를 변경하실 필요는 없을것 같습니다. TableName만...
    • 반정현
    • 1999.05.24 20:25
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 모승열
      1999.05.25 00:23
      반정현 wrote: > 저는 델파이 초보입니다. > > 시간함수 > time() > > 를 값으로 추출하여 ...
    • 이천주
    • 1999.05.24 20:04
    • 2 COMMENTS
    • /
    • 0 LIKES
    • 이정욱
      1999.05.24 22:17
      아래처럼 해보세요. 그냥 온라인상에서 바꿨으므로 약간의 수정이 필요할 수 있습니다. var netrc :...
    • 이천주
      1999.05.26 03:05
      "그냥 온라인상에서 바꿨으므로 약간의 수정이 필요할 수 있습니다." 그래서, 수정한 소스를 다른 분들을 ...