Check if the given vectors are at equilibrium or not | CPP program to check the equilibrium of three vectors ; Function to check the equilibrium of three vectors ; summing the x coordinates ; summing the y coordinates ; summing the z coordinates ; Checking the condition for equilibrium ; Driver code ; Checking for equilibrium
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool checkEquilibrium ( int x1 , int y1 , int z1 , int x2 , int y2 , int z2 , int x3 , int y3 , int z3 ) { int resx = x1 + x2 + x3 ; int resy = y1 + y2 + y3 ; int resz = z1 + z2 + z3 ; if ( resx == 0 and resy == 0 and resz == 0 ) return true ; else return false ; } int main ( ) { int x1 = -2 , y1 = -7 , z1 = -9 , x2 = 5 , y2 = -14 , z2 = 14 , x3 = -3 , y3 = 21 , z3 = -5 ; if ( checkEquilibrium ( x1 , y1 , z1 , x2 , y2 , z2 , x3 , y3 , z3 ) ) cout << " The ▁ vectors ▁ are ▁ at ▁ equilibrium . " ; else cout << " The ▁ vectors ▁ are ▁ not ▁ at ▁ equilibrium . " ; return 0 ; }