作业帮 > 综合 > 作业

c++ 题目;实现算数表达式的计算

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/17 07:54:35
c++ 题目;实现算数表达式的计算
要求:用户输入表达式,其中包括字符有:+、-、*、/、)、(和数字,编程完成计算结果并打印出.实现算数表达式的计算
// 加减乘除.cpp :Defines the entry point for the console application.
//
#include "stdafx.h"
#include
using namespace std;
class cal //加减乘出计算类
{
public:
int add(int x,int y) //加法定义函数
{
return x+y;
}
int sub(int x,int y) //减法定义函数
{
return x-y;
}
int mul(int x,int y) //乘法定义函数
{
return x*y;
}
int div(int x,int y) //除法定义函数
{
if(y==0)
cout