Advertisement
icatalin

problema 9.24 baza

Sep 24th, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. ifstream f("date.in");
  7. ofstream g("date.out");
  8.  
  9. int main()
  10. {
  11.     int a,b,c,d,e;
  12.     int n1,n2,dif;//n1=abcbe,n2=edab,n=ebce
  13.     n1=a*10000+b*1000+c*100+b*10+e;
  14.     n2=e*1000+d*100+a*10+b;
  15.     for (a=1;a<=9;a++)
  16.     for (e=1;e<=9;e++)
  17.     for (b=0;b<=9;b++)
  18.     for (c=0;c<=9;c++)
  19.     for (d=0;d<=9;d++)
  20.     {
  21.         n1=a*10000+b*1000+c*100+b*10+e;
  22.         n2=e*1000+d*100+a*10+b;
  23.         dif=e*1000+b*100+c*10+e;
  24.         if (n1-n2==dif)
  25.         cout<<n1<<"-"<<n2<<"="<<dif;
  26.     }
  27.  
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement