FazEN

Untitled

Mar 15th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4.  
  5.  
  6. int main() {
  7. int a1,a2,a3,b;
  8. bool x=false;
  9. cin>>b;
  10. for (int d=0;d<=9;++d) {
  11. for (int i=1;i<=9;++i) {
  12. for (int j=0;j<=9;++j) {
  13. if (i+j==d)
  14. {
  15. a2=i*10+j;
  16. if (((b-(d+a2))/10+(b-(d+a2))%10)==a2)
  17. {
  18. cout<<b-(d+a2);
  19. x=true;
  20. }
  21. else if (d==9 && ((b-(d+a2))/10+(b-(d+a2))%10)!=a2)
  22. {
  23. cout<<-1;
  24. x=true;
  25. }
  26.  
  27.  
  28. }
  29. if (x==true) {
  30. break;
  31. }
  32.  
  33. }
  34. if (x==true) {
  35. break;
  36. }
  37.  
  38. }
  39. if (x==true) {
  40. break;
  41. }
  42. }
  43.  
  44.  
  45.  
  46. return 0;
  47.  
  48. }
Add Comment
Please, Sign In to add comment