I want to know how to create the following pattern using *
and _
using nested loops.
*_______*
__*___*
____*
__*___*
*_______*
I am currently trying to do this in Java, but an answer in C will do as well, I can extrapolate the answer. Here is a pic to better understand the pattern required.
I understand that I need to have some code to start with , but I cant manage to work out the logic.
Is there any algo/technique that anyone can guide me towards in order to be able to attempt this, some Karnaugh map like technique.
for(int i =0; i < 5; i++){
for(int j = 0; j < 9; j++){
if(j==2*i || 8-2*i == j)
System.out.print("*");
else if(8-2*i < j && j > 2*i)
break;
else
System.out.print("_");
}
System.out.println();
}