Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main() {
- int a1,a2,a3,b;
- bool x=false;
- cin>>b;
- for (int d=0;d<=9;++d) {
- for (int i=1;i<=9;++i) {
- for (int j=0;j<=9;++j) {
- if (i+j==d)
- {
- a2=i*10+j;
- if (b-(d+a2)==0) {
- cout<<a2;
- x=true;
- }else
- {
- if (((b-(d+a2))/10+(b-(d+a2))%10)==a2)
- {
- cout<<b-(d+a2);
- x=true;
- }
- else if (d==9 && ((b-(d+a2))/10+(b-(d+a2))%10)!=a2)
- {
- cout<<-1;
- x=true;
- }
- }
- }
- if (x==true) {
- break;
- }
- }
- if (x==true) {
- break;
- }
- }
- if (x==true) {
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement