Advertisement
FazEN

Untitled

Mar 15th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 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)==0) {
  17. cout<<a2;
  18. x=true;
  19. }else
  20. {
  21.  
  22. if (((b-(d+a2))/10+(b-(d+a2))%10)==a2)
  23. {
  24. cout<<b-(d+a2);
  25. x=true;
  26. }
  27. else if (d==9 && ((b-(d+a2))/10+(b-(d+a2))%10)!=a2)
  28. {
  29. cout<<-1;
  30. x=true;
  31. }
  32.  
  33. }
  34.  
  35. }
  36. if (x==true) {
  37. break;
  38. }
  39.  
  40. }
  41. if (x==true) {
  42. break;
  43. }
  44.  
  45. }
  46. if (x==true) {
  47. break;
  48. }
  49. }
  50.  
  51.  
  52.  
  53. return 0;
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement