学了c++后 能用库函数的都用吧,几乎都是极致了
#include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;

int main() {

    char str[100] = { 0 };
    cin.getline(str, sizeof(str));

    // write your code here......
    char* ch[4] = { str , NULL};
    int i = 0;
    while((ch[i++] = strtok(ch[i]," ") ) != NULL);
    
    int a = atoi(ch[1]);
    int b = atoi(ch[2]);
    
    if     ( strcasecmp(ch[0],"add") == 0 )
    {
        cout << a + b;
    }
    else if( strcasecmp(ch[0],"sub") == 0 )
    {
        cout << a - b;
    }
    else if( strcasecmp(ch[0],"mul") == 0  )
    {
        cout << a * b;
    }
    else if( strcasecmp(ch[0],"div") == 0  )
    {
        if(b == 0)
            cout << "Error" ;
        else 
            cout << a / b;
    }

    return 0;
}