#include
void Input(double *num1, double *num2, char *kiho);
double plus(double *p1, double *p2);
double minus(double *m1, double *m2);
double mul(double *mu1, double *mu2);
double div(double *d1, double *d2);
int main()
{
double num1, num2;
int cnt[4] = {0};
char kiho, sel;
do
{
Input(&num1, &num2, &kiho);
switch(kiho)
{
case '+':
printf("%.2f + %.2f = %.2f\n\n", num1, num2, plus(&num1, &num2));
cnt[0]++;
break;
case '-':
printf("%.2f - %.2f = %.2f\n\n", num1, num2, minus(&num1, &num2));
cnt[1]++;
break;
case '*':
printf("%.2f * %.2f = %.2f\n\n", num1, num2, mul(&num1, &num2));
cnt[2]++;
break;
case '/':
printf("%.2f / %.2f = &.2f\n\n", num1, num2, div(&num1, &num2));
cnt[3]++;
break;
default:
printf("올바른 연산자를 입력하시오\n");
continue;
}
printf("\n\n\t 계속, 종료을 누른후 Enter를 누르시오 : ");
sel = getchar();
fflush(stdin);
if(sel == 'N' || sel == 'n')
{
printf("\n\n");
printf("덧 셈 : %d회\n", cnt[0]);
printf("뺄 셈 : %d회\n", cnt[1]);
printf("곱 셈 : %d회\n", cnt[2]);
printf("나눗셈 : %d회\n", cnt[3]);
}
else if(sel == 'Y' || sel == 'y')
{
continue;
}
else
{
printf("\tY/y 또는 N/n만 입력하시오\n\n");
continue;
}
}while(sel != 'N' && sel != 'n');
return 0;
}
void Input(double *num1, double *num2, char *kiho)
{
printf("첫번째 수 : ");
scanf("%lf", num1);
fflush(stdin);
printf("두번째 수 : ");
scanf("%lf", num2);
fflush(stdin);
printf("더하기[+], 빼기[-], 곱하기[*], 나누기[/] : [ ]\b\b");
*kiho = getchar();
fflush(stdin);
}
double plus(double *p1, double *p2)
{
return *p1 + *p2;
}
double minus(double *m1, double *m2)
{
return *m1 - *m2;
}
double mul(double *mu1, double *mu2)
{
return *mu1 * *mu2;
}
double div(double *d1, double *d2)
{
return *d1 / *d2;
}