계산기인데요...
뭐가 틀렸는지 봐주세요.
제멜은 kingjun25@naver.com 입니다 ...ㅜ
/* Example 017 2009.6.4 Call by Reference II */
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <bios.h>
int I, J;
int P1, P2;
int SL;
char CA[10],CB[10],CC[10];
char TP;
float DB,DC,DT;
void InitVar(void);
void NumberInput(int);
main(void)
{
clrscr();
NumberInput(1);
if ((TP=='+')||(TP=='-')||(TP=='*')||(TP=='/')) {
switch(TP)
case '+' : SL = 1; break;
case '-' : SL = 2; break;
case '*' : SL = 3; break;
case '/' : SL = 4; break;
}
goto AA12;
AA12: gotoxy(1,3); printf("Inputed=%9.3f",DB);
gotoxy(1,4); printf(" SL =%1d",SL);
//2nd Numner
NumberInput(2);
if ((TP== '=')||(TP==0x0D)) goto AA22;
AA22:
switch(SL) {
case 1: DT = DB + DC;
gotoxy(1,10);
printf("%9.3f = %9.3f + %9.3f",DT,DB,DC);
break;
switch(SL) {
case 2: DT = DB - DC;
gotoxy(1,10);
printf("%9.3f = %9.3f - %9.3f",DT,DB,DC);
break; switch(SL) {
case 3: DT = DB * DC;
gotoxy(1,10);
printf("%9.3f = %9.3f * %9.3f",DT,DB,DC);
break; switch(SL) {
case 4: DT = DB / DC;
gotoxy(1,10);
printf("%9.3f = %9.3f / %9.3f",DT,DB,DC);
break;
}
gotoxy(40,1); printf("Bye~!");
getch();
return(0);
}
void InitVar(void)
{
P1 = 0
P2 = 0
for (I - 0; I <= 10; I++) {
CA[I] = 0x0D;
CB[I] = 0x0D;
}
I = 0;
}
void NumberInput(int Px)
{
N11:
gotoxy(1,(Px-1)*1; TP = getch();
if ((TP >= '0')&&(TP <= '9')) {
CA[I] = TP;
I++;
gotoxy(10,((Px-1)*1)+2); printf("%s",CA);
goto N11;
}
if (((TP == '.')&&(P1 == 0))||((TP == '.')&&(P2 == 0))) {
CA[I] = TP;
I++;
switch(Px) {
case 1: P1 = 1; break;
case 2: P2 = 2; break;
}
gotoxy(10,(Px-1)*5+2); printf("%s",CA);
goto N11;
}
for (J = 0; J < I; J++) CB[J] = CA[J];
switch(Px) {
case 1: DB = atof(CB); break;
case 2: DC = atof(CB); break;
}
gotoxy(1,(Px-1)*5+8); printf("Inputed=%9.3f",DC);
}
|