Qin’s Solution for basicMath problem:

# include <iostream>
# include <string>
using namespace std;

# define addition (a)+(b)
# define subduction (a) – (b)
# define multiplication (a) * (b)
# define division (a) / (b)

int findNumber(char* _num){
int i = 0;
int count = 1;
if(_num[i]==’-‘)
i++;
do{
if(_num[i] < 0 || _num[i] > 9){
count = 0;
}
if(_num[i] == ‘.’)
i++;
else
i++;
}while(_num[i]!=’ ‘);
if(count)
return true;
else
return false;

}
int main(int arg,char* argChar[]){
if(arg !=4 ){
cout << “bm <number><+-*/><number><Enter>” << endl;
return 0;
}
if( findNumber(argChar[1]) && findNumber(argChar[3]) ){
double a =0;
double b =0;
double c= 0;
if(argChar[2]==”+”){
a = atof(argChar[1]);
b = atof(argChar[3]);
c = addition;
}
if( findNumber(argChar[1]) && findNumber(argChar[3]) ){
if(argChar[2]==”-“){
a = atof(argChar[1]);
b = atof(argChar[3]);
c = subduction;

}
if(argChar[2]==”*”){
a = atof(argChar[1]);
b = atof(argChar[3]);
c = multiplication;

}
if(argChar[2]==”/”){
a = atof(argChar[1]);
b = atof(argChar[3]);
c = division;

}
cout << c << endl;
}
else{
cout << “bm <number><+-*/><number><Enter>” << endl;
return 0;
}

}

Standard