Advertisement
istinishat

common segment

Sep 23rd, 2016
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int func(int l1,int r1,int l2,int r2)
  6. {
  7.     return max(0,min(r1,r2)-max(l1,l2));
  8. }
  9.  
  10. int main()
  11. {
  12.     cout<<func(0,5,6,10)<<endl;
  13.     return 0;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement