Advertisement
FazEN

Untitled

Mar 15th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. //#include<iostream>
  2. //using namespace std;
  3.  
  4. //int main(){
  5. // int n,position,numbertoInsert,buf;
  6. // cin>>n;
  7.  
  8. // int arr[n];
  9. // for(int i=0; i<n; i++){
  10. // cin>>arr[i];
  11. // }
  12. // cin>>numbertoInsert>>position;
  13.  
  14. // if(position>=n)
  15. // {
  16. // position=n-1;
  17. // }
  18. // buf=arr[n-1];
  19. // for(int i=n-1; i>position; i--)
  20. // {
  21. // arr[i]=arr[i-1];
  22.  
  23. // }
  24.  
  25. // arr[position]=numbertoInsert;
  26. // for(int i=0; i<n; i++)
  27. // {
  28. // cout<<arr[i]<<" ";
  29. // }
  30.  
  31. // return 0;
  32. //}
  33. #include<iostream>
  34. using namespace std;
  35.  
  36.  
  37.  
  38. int main() {
  39. int a1,a2,a3,b;
  40. bool x=false;
  41. cin>>b;
  42. for (int d=0;d<=9;++d) {
  43. for (int i=1;i<=9;++i) {
  44. for (int j=0;j<=9;++j) {
  45. if (i+j==d)
  46. {
  47. a2=i*10+j;
  48. if (((b-(d+a2))/10+(b-(d+a2))%10)==a2)
  49. {
  50. cout<<b-(d+a2);
  51. x=true;
  52. }
  53. else if (d==9 && ((b-(d+a2))/10+(b-(d+a2))%10)!=a2)
  54. {
  55. cout<<-1;
  56. x=true;
  57. }
  58.  
  59.  
  60. }
  61. if (x==true) {
  62. break;
  63. }
  64.  
  65. }
  66. if (x==true) {
  67. break;
  68. }
  69.  
  70. }
  71. if (x==true) {
  72. break;
  73. }
  74. }
  75.  
  76.  
  77.  
  78. return 0;
  79.  
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement