#25199: C++三行解


nathanlee850 (Nathan850)

學校 : 臺北市立明倫高級中學
編號 : 136982
來源 : [1.200.25.146]
最後登入時間 :
2024-04-15 18:05:10
f698. 後序運算式 -- 板橋高中教學題 | From: [203.72.58.252] | 發表日期 : 2021-04-28 12:46

#include <bits/stdc++.h>

using namespace std;

int main()

{string s,c;int a,b;while(getline(cin,s)){stack<long long int> st;stringstream ss;ss<<s;while(ss>>c){if(c=="+"){a=st.top();st.pop();b=st.top();st.pop();st.push(a+b);}else if(c=="-"){a=st.top();st.pop();b=st.top();st.pop();st.push(b-a);}else if(c=="*"){a=st.top();st.pop();b=st.top();st.pop();st.push(a*b);}else if(c=="/"){a=st.top();st.pop();b=st.top(); st.pop();st.push(b/a);}else{st.push(stoi(c));}}cout<<st.top()<<"\n";}}

 
#25200: Re:C++三行解


agar.io6100@gmail.com (企鵝)

學校 : 臺北市立明倫高級中學
編號 : 105222
來源 : [180.217.50.84]
最後登入時間 :
2023-05-23 15:15:43
f698. 後序運算式 -- 板橋高中教學題 | From: [203.72.58.252] | 發表日期 : 2021-04-28 12:47

#include <bits/stdc++.h>

using namespace std;

int main()

{string s,c;int a,b;while(getline(cin,s)){stack st;stringstream ss;ss<<s;while(ss>>c){if(c=="+"){a=st.top();st.pop();b=st.top();st.pop();st.push(a+b);}else if(c=="-"){a=st.top();st.pop();b=st.top();st.pop();st.push(b-a);}else if(c=="*"){a=st.top();st.pop();b=st.top();st.pop();st.push(a*b);}else if(c=="/"){a=st.top();st.pop();b=st.top(); st.pop();st.push(b/a);}else{st.push(stoi(c));}}cout<<st.top()<<"\n";}}

三小東西

 
#25201: Re:C++三行解


nathanlee850 (Nathan850)

學校 : 臺北市立明倫高級中學
編號 : 136982
來源 : [1.200.25.146]
最後登入時間 :
2024-04-15 18:05:10
f698. 後序運算式 -- 板橋高中教學題 | From: [203.72.58.252] | 發表日期 : 2021-04-28 12:48

#include <bits/stdc++.h>

using namespace std;int main(){string s,c;int a,b;while(getline(cin,s)){stack<long long int> st;stringstream ss;ss<<s;while(ss>>c){if(c=="+"){a=st.top();st.pop();b=st.top();st.pop();st.push(a+b);}else if(c=="-"){a=st.top();st.pop();b=st.top();st.pop();st.push(b-a);}else if(c=="*"){a=st.top();st.pop();b=st.top();st.pop();st.push(a*b);}else if(c=="/"){a=st.top();st.pop();b=st.top(); st.pop();st.push(b/a);}else{st.push(stoi(c));}}cout<<st.top()<<"\n";}}



 
#25202: Re:C++三行解


martin0968872985@gmail.com (DISESFGEWU)

學校 : 國立臺北科技大學
編號 : 108346
來源 : [140.124.249.22]
最後登入時間 :
2023-10-16 17:30:34
f698. 後序運算式 -- 板橋高中教學題 | From: [203.72.58.252] | 發表日期 : 2021-04-28 12:49

#include <bits/stdc++.h>

using namespace std;

int main()

{string s,c;int a,b;while(getline(cin,s)){stack st;stringstream ss;ss<<s;while(ss>>c){if(c=="+"){a=st.top();st.pop();b=st.top();st.pop();st.push(a+b);}else if(c=="-"){a=st.top();st.pop();b=st.top();st.pop();st.push(b-a);}else if(c=="*"){a=st.top();st.pop();b=st.top();st.pop();st.push(a*b);}else if(c=="/"){a=st.top();st.pop();b=st.top(); st.pop();st.push(b/a);}else{st.push(stoi(c));}}cout<<st.top()<<"\n";}}


那學弟你也很有特色ㄟ

 
#25593: Re:C++三行解


810416@fhsh.khc.edu.tw (Eric_hung)

學校 : 國立鳳新高級中學
編號 : 118851
來源 : [140.116.118.9]
最後登入時間 :
2022-11-09 15:13:56
f698. 後序運算式 -- 板橋高中教學題 | From: [101.9.172.205] | 發表日期 : 2021-06-05 00:29

#include <bits/stdc++.h>

using namespace std;

int main()

{string s,c;int a,b;while(getline(cin,s)){stack st;stringstream ss;ss<<s;while(ss>>c){if(c=="+"){a=st.top();st.pop();b=st.top();st.pop();st.push(a+b);}else if(c=="-"){a=st.top();st.pop();b=st.top();st.pop();st.push(b-a);}else if(c=="*"){a=st.top();st.pop();b=st.top();st.pop();st.push(a*b);}else if(c=="/"){a=st.top();st.pop();b=st.top(); st.pop();st.push(b/a);}else{st.push(stoi(c));}}cout<<st.top()<<"\n";}}

 

 

笑死

 
#33247: Re: C++三行解


leo950518test (耶嘿一灘爛泥)

學校 : 國立嘉義高級中學
編號 : 199798
來源 : [114.39.186.142]
最後登入時間 :
2023-02-27 12:29:30
f698. 後序運算式 -- 板橋高中教學題 | From: [163.27.3.122] | 發表日期 : 2022-12-16 12:45

#include

using namespace std;

int main()

{string s,c;int a,b;while(getline(cin,s)){stack st;stringstream ss;ss<>c){if(c=="+"){a=st.top();st.pop();b=st.top();st.pop();st.push(a+b);}else if(c=="-"){a=st.top();st.pop();b=st.top();st.pop();st.push(b-a);}else if(c=="*"){a=st.top();st.pop();b=st.top();st.pop();st.push(a*b);}else if(c=="/"){a=st.top();st.pop();b=st.top(); st.pop();st.push(b/a);}else{st.push(stoi(c));}}cout<

這尛...

那我還可以一行解

 
ZeroJudge Forum