fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int D, E, Q;
  6. char C;
  7.  
  8. cin>>D>>E;
  9.  
  10. while(E--){
  11. cin>>C>>Q;
  12.  
  13. switch(C){
  14. case '+':
  15. D+=Q;
  16. break;
  17. case '-':
  18. D-=Q;
  19. break;
  20. }
  21. }
  22.  
  23. cout<<D;
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0.01s 5296KB
stdin
10
3
+
24
-
6
-
12
stdout
16