Advertisement
Guest User

Untitled

a guest
Nov 11th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3. Online C++ Compiler.
  4. Code, Compile, Run and Debug C++ program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <iostream>
  10. #include <cmath>
  11. #include <string>
  12.  
  13. using namespace std;
  14.  
  15. int rep(int n){
  16. int x, endx = 0;
  17.  
  18. // if (n==0){
  19. // return endx;
  20. // }
  21.  
  22. string s;
  23. cin >> s;
  24.  
  25. while (s!="BLE"){
  26. if (s=="MOV"){
  27. cin >> x;
  28. endx+=x;
  29. }
  30.  
  31. if (s=="REP"){
  32. cin >> x;
  33. cin >> s;
  34. endx+=rep(x);
  35. }
  36.  
  37. cin >> s;
  38. }
  39.  
  40. return endx*n;
  41. }
  42.  
  43. int main()
  44. {
  45. string s;
  46. int x, endx=0;
  47.  
  48. while(cin >> s){
  49. if (s=="MOV"){
  50. cin >> x;
  51. endx+=x;
  52. }
  53. if (s=="REP"){
  54. cin >> x;
  55. cin >> s;
  56. endx+=rep(x);
  57. }
  58. }
  59.  
  60. cout << endx;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement