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
Selected Reading
Maximum points of intersection n lines in C++
In this tutorial, we will be discussing a program to find maximum points of intersection n lines
For this we will be provided with a number of straight lines. Our task is to find the maximum number of intersections the given number of lines meet.
Example
#include <bits/stdc++.h>
using namespace std;
#define ll long int
//finding maximum intersection points
ll countMaxIntersect(ll n) {
return (n) * (n - 1) / 2;
}
int main() {
ll n = 8;
cout << countMaxIntersect(n) << endl;
return 0;
}
Output
28
Advertisements
