Click here to Skip to main content
15,908,264 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
0 1 2 3 4 5 6 7 8 9
. . . . . * . . . . 
. . . . . . . * . .
. . . . * . . . . .
. . * . . . . . . .


[edit] Code block added[/edit]
Posted
Updated 11-Feb-15 20:19pm
v2
Comments
Jeet Gupta 12-Feb-15 2:08am    
can you explain your problem little briefly. whats the exact pattern you want

better is a solution with some more intelligence.

I wrote some code, I hope it works, but it should show my concept.
- for Loop for line output
- flag array to print stars

C++
for( int i = 0; i < 8; i++)
{
printf("0"+i);
}
printf("\n");

int stars[] = {5,7,4,2};

for(int l = 0; l < 4; l++)//outer loop
{
for(int i = 0; i < 8; i++)//inner loop
{
if( stars[l] == i ) ? printf("*") : printf(" ");
}
printf("\n");
}
 
Share this answer
 
Comments
CPallini 12-Feb-15 3:06am    
5. The 'data driven' solution.
We can't answer this with a generalised solution based on that little information: we have no idea what rules you are using to generate the pattern.

So the only answer we can give you is trivial:
C++
printf("0 1 2 3 4 5 6 7 8 9\n");
printf(". . . . . * . . . .\n");
printf(". . . . . . . * . .\n");
printf(". . . . * . . . . .\n");
printf(". . * . . . . . . .\n");

If you want a generalised sojourn, then you need to consider the rules that govern the generation of the pattern.
 
Share this answer
 
Comments
CPallini 12-Feb-15 3:05am    
5. Short and to the point. :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900