#25199: C++三行解


nathanlee850 (Nathan850)

學校 : 臺北市立明倫高級中學
編號 : 136982
來源 : [140.119.235.6]
最後登入時間 :
2025-10-02 21:23:28

#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
來源 : [223.139.174.164]
最後登入時間 :
2024-09-30 11:29:34

#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
來源 : [140.119.235.6]
最後登入時間 :
2025-10-02 21:23:28

#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

#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

#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

#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<

這尛...

那我還可以一行解