Skip to content

Instantly share code, notes, and snippets.

@jeremy5189
Created October 11, 2013 07:00
Show Gist options
  • Save jeremy5189/6930658 to your computer and use it in GitHub Desktop.
Save jeremy5189/6930658 to your computer and use it in GitHub Desktop.
/*
* Author: Jeremy Yen Date: 2013.10.11
* http://oj.sslab.cs.nthu.edu.tw/problems/11
*
*/
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n, i, j, k;
scanf("%d", &n);
for( i = 3; i <= (n+2); i++ )
{
for( j = 1; j <= i; j++ )
{
int star_count = 2 * j - 1;
int space_count = ((2 * (n + 2) - 1) / 2);
space_count -= (int)(star_count / 2 );
for( k = 0; k < space_count; k++ )
printf(" ");
for( k = 0; k < star_count; k++ )
printf("*");
for( k = 0; k < space_count; k++ )
printf(" ");
printf("\n");
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment