Use code and output tags for legibility. Format options on the right,
for code, [co
de] your code here
de]. Similarly for output.
Both the source code and output are unreadable without these tags.
Well, this looks like C code rather than C++. If that's what you are required to do, it limits some of the options available. But still the code can be simplified and shortened quite a lot.
First, you can make better use of the formatting options of
Second, you could use the ternary operator to simplify the code. You might also consider the use of
as alternatives to printf and scanf when dealing with a single character.or a straightforward string.
If you do those things, this block reduces to a single line of code:
if( count > 9 )
printf( " %d ", count );
printf( " %d ", count);
and this reduces to one or two lines depending on taste:
if( n[ i ] >= count )
printf( "*" );
printf( " " );
In the first case above, use a suitable printf format string.
In the second, use the ternary operator.
I got the code down to 25 lines, and that includes several blank lines for readability. (If I scrunch it up until it looks ugly, it's down to 16 lines).
see "conditional operator" on this page:
and printf here http://www.cplusplus.com/reference/clibrary/cstdio/printf/