Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int a=0,q,p;
- string s;
- cin>>s>>q;
- vector <int> k;
- for (int i=0;i<s.size();i++)
- {
- if (s[i]=='+')
- {
- a+=2;
- }
- else if (s[i]=='/')
- {
- a/=2;
- }
- else if (s[i]=='*')
- {
- a*=2;
- }
- else if (s[i]=='-')
- {
- a-=2;
- }
- k.push_back(a);
- }
- for (int j=0;j<q;j++)
- {
- cin>>p;
- cout<<k[p-1]<<' ';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement