Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- int T,a[100],b[100],c[100],i;
- cin>>T;
- cout<<endl;
- //to get the input:
- for(i=0;i<T;i++)
- {cin>>a[i]>>b[i]>>c[i];
- cout<<endl;
- }
- //core code of the problem:
- for(i=0;i<T;i++)
- {
- while(c[i])
- {if(a[i]>b[i])
- {b[i]++;
- c[i]--;
- }
- else if(b[i]>a[i])
- {a[i]++;
- c[i]--;
- }
- else if(a[i]==b[i])
- break;
- }
- if(a[i]>b[i])
- cout<<a[i]-b[i]<<endl;
- else
- cout<<b[i]-a[i]<<endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment