Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int p,k;
- cin>>p>>k;
- int a,b,c,d;
- int x,y,z,l;
- d=p%10;
- c=(p/10)%10;
- b=(p/100)%10;
- a=(p/1000)%10;
- l=k%10;
- z=(k/10)%10;
- y=(k/100)%10;
- x=(k/1000)%10;
- int zbir=0;
- if(d>l)
- {
- if((d-l)>((10-d)+l))
- {
- zbir+=((10-d)+l);
- }else
- {
- zbir+=d-l;
- }
- }else
- {
- if((l-d)>((10-l)+d))
- {
- zbir+=((10-l)+d);
- }else
- {
- zbir+=l-d;
- }
- }
- if(c>z)
- {
- if((c-z)>((10-c)+z))
- {
- zbir+=((10-c)+z);
- }else
- {
- zbir+=c-z;
- }
- }else
- {
- if((z-c)>((10-z)+c))
- {
- zbir+=((10-z)+c);
- }else
- {
- zbir+=z-c;
- }
- }
- if(b>y)
- {
- if((b-y)>((10-b)+y))
- {
- zbir+=((10-b)+y);
- }else
- {
- zbir+=b-y;
- }
- }else
- {
- if((y-b)>((10-y)+b))
- {
- zbir+=((10-y)+b);
- }else
- {
- zbir+=y-b;
- }
- }
- if(a>x)
- {
- if((a-x)>((10-a)+x))
- {
- zbir+=((10-a)+x);
- }else
- {
- zbir+=a-x;
- }
- }else
- {
- if((x-a)>((10-x)+a))
- {
- zbir+=((10-x)+a);
- }else
- {
- zbir+=x-a;
- }
- }
- cout<<zbir;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement