Minimum increment in the sides required to get non | C ++ program to find Minimum increase in sides to get non - negative area of a triangle ; Function to return the minimum increase in side lengths of the triangle ; push the three sides to a array ; sort the array ; check if sum is greater than third side ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int minimumIncrease ( int a , int b , int c ) { int arr [ ] = { a , b , c } ; sort ( arr , arr + 3 ) ; if ( arr [ 0 ] + arr [ 1 ] >= arr [ 2 ] ) return 0 ; else return arr [ 2 ] - ( arr [ 0 ] + arr [ 1 ] ) ; } int main ( ) { int a = 3 , b = 5 , c = 10 ; cout << minimumIncrease ( a , b , c ) ; return 0 ; }