#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<map>
#include<vector>
#include<queue>
#include<iostream>
#include<stack>
using namespace std;
char s[105];
stack<int>s2;
stack<char>s1;
int F(char c) //为各种运算符赋值(根据优先级大小),便于对比
{
switch(c)
{
case'=':return 1;
case'+':return 2;
case'-':return 2;
case'*':return 3;
case'/':return 3;
case'^':return 4;
case'(':return 0;
case')':return 0;
}
}
int fun(int a,int b) //计算次方
{
int ans=1;
for(int i=1; i<=b; i++)
ans*=a;
return ans;
}
int calc(int a,int b,char c) //加减乘除次方的运算
{
switch(c)
{
case'+':return a+b;
case'-':return a-b;
case'*':return a*b;
case'/':return a/b;
case'^
表达式计算(加减乘除次方)
最新推荐文章于 2021-08-11 20:26:27 发布