Skip to content

Instantly share code, notes, and snippets.

@samc
Created September 27, 2017 00:17
Show Gist options
  • Save samc/e8965a0f1a1b97d35a687b32ff9ae2e0 to your computer and use it in GitHub Desktop.
Save samc/e8965a0f1a1b97d35a687b32ff9ae2e0 to your computer and use it in GitHub Desktop.
int
main ()
{
// for loop execution
for (int q = 1; q <= 10; q = q + 1)
{
for (int qq = 1; qq <= 4; qq = qq + 1)
{
if (qq == 1)
{
for (int a = 1; a <= 10; a = a + 1)
{
if (a <= q)
{
cout << '*';
}
else
{
cout << ' ';
}
}
}
if (qq == 2)
{
for (int b = 1; b <= 10; b = b + 1)
{
if (b <= (10 -q))
{
cout << '*';
}
else
{
cout << ' ';
}
}
}
if (qq == 3)
{
for (int c = 1; c <= 10; c = c + 1)
{
if (c >= q)
{
cout << '*';
}
else
{
cout << ' ';
}
}
}
if (qq == 4)
{
for (int d = 1; d <= 10; d = d + 1)
{
if (d > (10 - q))
{
cout << '*';
}
else
{
cout << ' ';
}
}
}
}
std::cout << std::endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment