Find N distinct integers with zero sum | C ++ implementation to Print N distinct numbers such that their sum is 0 ; Function to print distinct n numbers such that their sum is 0 ; Print 2 symmetric numbers ; print a extra 0 if N is odd ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void findNumbers ( int N ) { for ( int i = 1 ; i <= N / 2 ; i ++ ) { cout << i << " , ▁ " << - i << " , ▁ " ; } if ( N % 2 == 1 ) cout << 0 ; } int main ( ) { int N = 10 ; findNumbers ( N ) ; }