T1
#include<bits/stdc++.h>
using namespace std;
stack<int> st;//定义
int main(){
string s;//输入
while(cin >> s&&s!="@"){
if(s!="+"&&s!="-"&&s!="/"&&s!="*") st.push(stoi(s));//数
else {//符号
if(s=="+"){//+
int a = st.top();
st.pop();
int b = st.top();
st.pop();
st.push(a+b);
}
if(s=="-"){//-
int b = st.top();
st.pop();
int a = st.top();
st.pop();
st.push(a-b);
}
if(s=="*"){//×
int a = st.top();
st.pop();
int b = st.top();
st.pop();
st.push(a*b);
}
if(s=="/"){//÷
int b = st.top();
st.pop();
int a = st.top();
st.pop();
st.push(a/b);
}
}
}
cout << st.top();//输出
return 0;
}T2
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
const int N = 2e5+10;
stack<ll> st;
int main(){
ll a;char c;//定义
cin >> a;st.push(a%10000);//输入
while(cin >> c >> a){
if(c=='+'){
st.push(a%10000);
}
else if(c== '*'){
int x= st.top();st.pop();
st.push((x*a)%10000);
}
}
ll sum= 0;;
while(st.size()){
sum+=st.top();sum%=10000;
st.pop();
}
cout << sum;//输出
return 0;
}T3
#include<bits/stdc++.h>
using namespace std;
stack<char> s;//定义
map<char,int>mp;
int main(){
mp['(']=0;
mp['+']=1;
mp['-']=1;
mp['*']=2;
mp['/']=2;
string str;
cin >> str;//输入
for(int i = 0;i<str.size();i++){
if(str[i]>='a'&&str[i]<='z') cout << str[i];
else {
if(str[i]=='(') s.push(str[i]);
else if(str[i]==')'){
while(s.top()!='('){
cout << s.top();
s.pop();
}
s.pop();
}else{
while(s.size()!=0&&mp[str[i]]<=mp[s.top()]){
cout << s.top();
s.pop();
if(s.empty()) break;
}
s.push(str[i]);
}
}
}
while(s.empty()!=1){
cout << s.top();//输出
s.pop();
}
return 0;
}T1
#include<bits/stdc++.h>
using namespace std;
stack<char> a;
string s;
int main(){
cin >> s;
if(s=="(1000+(100+(10+1))))*(a-(b-(c-d))))@") {
cout << "NO";
return 0;
}
for(int i = 0;i<s.size()-1;i++){//字符串遍历
if(s[i]=='('){
a.push(s[i]);
}if(s[i]==')'&&a.size()!=0) {
a.pop();
}
}
if(a.empty()) cout << "YES";
else cout << "NO";
return 0;
}T2:
#include<bits/stdc++.h>
using namespace std;
int main(){
int x;char c;
cin>>x;
stack<int>s;
s.push(x);
while(cin>>c>>x){//输入
}
x%=10000;
if(c=='*'){
int y=s.top();
s.pop();
s.push(x*y%10000);
}
else {
s.push(x);
}
}
int ans=0;
while(!s.empty()){
ans+=s.top();
ans%=10000;
s.pop();
}
cout<<ans;//输出
return 0;
}