Advertisement
mastermindjisan

Cut Ribbon

Mar 30th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. int main()
  5. {
  6. int a,pieces[4],i,j,count=1,ok=0,sum,bal=8;
  7. cin>>a;
  8. for(i=0;i<3;i++){
  9. cin>>pieces[i];
  10. }
  11. for(i=0;i<2;i++){
  12. cout<<pieces[i]<<"Piece";
  13. ok=ok+pieces[i];
  14. //cout<<"uprerok"<<ok<<endl;
  15. for(j=i+1;j<3;j++){
  16. //1cout<<ok<<endl;
  17. sum=ok+pieces[j];
  18. //cout<<"sum"<<sum<<endl;
  19. if(sum==a){
  20. count++;
  21. bal=1;
  22. //cout<<ok<<endl;
  23. break;
  24. } if(sum>a){
  25. ok=0;
  26. bal=2;
  27. //cout<<ok<<" "<<count<<endl;
  28. } if (sum<a){
  29. bal=0;
  30.  
  31. }
  32. //cout<<ok<<endl;
  33. }
  34. if(bal==1){
  35. //cout<<count<<" "<<bal<<endl;
  36. break;
  37. }
  38. else if(bal==2){
  39. count=count;
  40. //cout<<count<<" "<<bal<<endl;
  41. continue;
  42. } if(bal==0){
  43. count++;
  44. // cout<<count<<" "<<bal<<endl;
  45. continue;
  46. }
  47.  
  48.  
  49. }
  50. // cout<<count;
  51.  
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement