Rndp13
BAN USERPublic and private are both access specifiers in C++.
When a class is created or declared by default the specifier is private, to change the specifier to public one has to declare it with the public keyword.
The private members are private to the class or the object created from the class.
Those can't be accessed from the outside world, where the public functions are the interface to the outside world. Outside world can play with the data members using the public member functions .
int main()
{
int n,j = 0; int hashtab[10];
bool NEG_VAL = false;
printf("Enter the number = ");
scanf("%d", &n);
if(n < 0)
{
NEG_VAL = true;
n = n * -1;
}
for(j=0;j<10;j++)
{
hashtab[j] = 0;
}
while(n > 0)
{
j = n%10;
hashtab[j] = hashtab[j] + 1;
n = n/10;
}
if(NEG_VAL)
{
printf("Highest number formed = -");
for(j=1;j<=9;j++)
{
while(hashtab[j] > 0)
{
printf("%d", j);
--hashtab[j];
}
}
printf("\n");
}
else
{
printf("Highest number formed = ");
for(j=9;j>=0;j--)
{
while(hashtab[j] > 0)
{
printf("%d", j);
--hashtab[j];
}
}
}
printf("\n");
return 0;
}
it can be solved using the hash table.
- Rndp13 April 21, 2015