#include<stdio.h>

#include<iostream>

#include<string.h>

using namespace std;


double add(double operand1, double operand2) { return operand1 + operand2; }

double subtract(double operand1, double operand2) { return operand1 - operand2; }

double multiply(double operand1, double operand2) { return operand1 * operand2; }

double divide(double operand1, double operand2) { return operand1 / operand2; }

typedef double(*OPERATOR)(double, double);


OPERATOR operators[4] = {add, subtract, multiply, divide};


int main()

{

    char input_string[256];

    const char opcodes[] = "+-*/";

    cout << "usage : operand1 opcode operand2 (ex: 3*8 or 3 * 8)" << endl;

    cin.getline(input_string, sizeof(input_string));

    char* ptr = input_string;

    while(*ptr && !strchr(opcodes, *ptr)) ptr++;

    int opcode = int(strchr(opcodes, *ptr) - opcodes);

    double operand1 = atof(strtok(input_string, opcodes));

    double operand2 = atof(strtok(NULL, " "));

    cout << operand1 << " " << opcodes[opcode] << " " << operand2 << " = "

         << operators[opcode](operand1, operand2) << endl;

    getchar();

    return 0;

}



님들 저 소질 있나요? 뿌잉뿌잉.