Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
C++ program to find two points from two lines who are not same
Suppose we have two ranges (l1, r1), (l2, r2) represents two lines on x-axis. l1
So, if the input is like l1 = 2; r1 = 6; l2 = 3; r2 = 4, then the output will be a = 3, b = 4, other answers are also possible.
Steps
To solve this, we will follow these steps −
if l1 is same as l2, then: (increase l1 by 1) return l1 and l2
Example
Let us see the following implementation to get better understanding −
#includeusing namespace std; void solve(int l1, int r1, int l2, int r2) { if (l1 == l2) l1++; cout Input
2, 6, 3, 4Output
2, 3
Advertisements
