#include
#include
int Calculate(char* input, float *ret)
{
int returnRet = 0;
float num1, num2, symbol;
int len = strlen(input);
char* num1Str = (char*)malloc(sizeof(char) * len);
char* num2Str = (char*)malloc(sizeof(char) * len);
memset(num1Str, 0, len);
memset(num2Str, 0, len);
int getSymbol = 0;
for (int i = 0, j = 0; i < len; i++)
{
if (input[i] == '+' || input[i] == '-' || input[i] == '*' || input[i] == '/')
{
symbol = input[i];
getSymbol = 1;
continue;
}
if (getSymbol == 0)
num1Str[i] = input[i];
else
num2Str[j++] = input[i];
}
num1 = atof(num1Str);
num2 = atof(num2Str);
if(symbol == '+')
*ret = num1 + num2;
else if(symbol == '-')
*ret = num1 - num2;
else if(symbol == '*')
*ret = num1 * num2;
if(symbol == '/')
{
if(num2 != 0)
*ret = num1 / num2;
else
returnRet = 1;//data error
}
free(num2Str);
free(num1Str);
return returnRet;
}
int main(void)
{
float ret;
char input[100];
memset(input, 0, sizeof(input));
scanf("%s",input);
if(Calculate(input,&ret) == 0)
printf("%.2f",ret);
else
printf("data erro");
return 0;
}