Find the smallest positive number which can not be represented by given digits | CPP program to find the smallest positive number which can not be represented by given digits ; Function to find the smallest positive number which can not be represented by given digits ; Storing the count of 0 digit or store the value at 0 th index ; Calculates the min value in the array starting from 1 st index and also store it index . ; If its value at 0 th index is less than min value than either 10 , 100 , 1000 ... can 't be expressed ; If it value is greater than min value than iterate the loop upto first min value index and simply print it index value . ; Driver code ; Value of N is always 10 as we take digit from 0 to 9 ; Calling function
#include <bits/stdc++.h> NEW_LINE using namespace std ; void expressDigit ( int arr [ ] , int n ) { int min = 9 , index = 0 , temp = 0 ; temp = arr [ 0 ] ; for ( int i = 1 ; i < 10 ; i ++ ) { if ( arr [ i ] < min ) { min = arr [ i ] ; index = i ; } } if ( temp < min ) { cout << 1 ; for ( int i = 1 ; i <= temp + 1 ; i ++ ) cout << 0 ; } else { for ( int i = 0 ; i < min ; i ++ ) cout << index ; cout << index ; } } int main ( ) { int arr [ ] = { 2 , 2 , 1 , 2 , 1 , 1 , 3 , 1 , 1 , 1 } ; int N = 10 ; expressDigit ( arr , N ) ; return 0 ; }