fork(3) download
  1. #include <iostream>
  2. #include <stdio.h>
  3. using namespace std;
  4. int main()
  5. {
  6. int t;
  7. scanf("%d",&t);
  8. while(t--){
  9. long long int val;
  10. char op;
  11. scanf("%lld",&val);
  12. while(true){
  13. long long int x;
  14. cin>>op;
  15. if(op=='=')break;
  16. scanf("%lld",&x);
  17. //cout<<t<<endl;
  18. if(op=='+')val+=x;
  19. else if(op=='-')val-=x;
  20. else if(op=='*')val*=x;
  21. else val/=x;
  22. }
  23. printf("%lld\n",val);
  24. }
  25. }
Success #stdin #stdout 0s 3100KB
stdin
4

1 + 1 * 2 =

29 / 5 =

103 * 103 * 5 =

50 * 40 * 250 + 791 =
stdout
4
5
53045
500791