Skip to content

Instantly share code, notes, and snippets.

@hodduc
Created April 23, 2013 21:41
Show Gist options
  • Save hodduc/5447631 to your computer and use it in GitHub Desktop.
Save hodduc/5447631 to your computer and use it in GitHub Desktop.
#include<stdio.h>
int N;
char buf[100];
int main()
{
scanf("%d", &N);
for(int i = (N << 1); i >= 1; i--)
{
int len = ((i-N) >= 0) * i + ((i-N) < 0) * N;
int space = N ^ (((i-1) ^ N) & -((i-1) < N));
for(int j = 0; j < len-space; j++)
buf[j] = '*';
buf[len-space] = 0;
printf("%*s\n", len, buf);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment