#include<stdio.h>




int ask(int);

double run(char opcode, double operand1, double opernad2);



int main(void)

{

while(1)

{

    double operand1, operand2, result;

    int count = 0;

    char opcode,quit;


    count = ask(count);

    scanf("%lf", &operand1);

    count = ask(count);

    scanf("%lf", &operand2);

    printf("원하시는 연산기호를 입력하십시오 ");

    getchar();

    opcode = getchar();


    while(1)

    {

        if(opcode =='+'|| opcode == '-'|| opcode == '*'|| opcode == '/')

            {

            result = run(opcode, operand1, operand2);

            break;

            }

        else

            {

            printf("잘못된 연산기호 입니다. ");

            printf("다시 연산기호를 입력해 주십시오 ");

            getchar();

            opcode = getchar();

            }

    }


    printf(" %lf %c %lf = %lf ", operand1, opcode, operand2, result);


    printf(" 다시 하시겠습니까? (Y/n) ");

    getchar();

    quit = getchar();

    if(quit == 'N' || quit == 'n') 

        break;



}

    printf("Bye :) ");

    return 0;

}


int ask(int count)

{

    printf("%d번째 숫자를 입력해주십시오. ", ++count);

    return count;

}


double run(char opcode, double operand1, double operand2)

{

switch(opcode)

{

    case('+'):

        return operand1 += operand2;

        break;

    case('-'):

        return operand1 -= operand2;

        break;

    case('*'):

        return operand1 *= operand2;

        break;

    case('/'):

        return operand1 /= operand2;

}

}


뭔가가 더 잘못된 느낌인데