#include #include void d_line(unsigned int i, unsigned int n) { unsigned int j; for (j = 0; j < n - i; j++) putchar(' '); for (j = 0; j < (2*i - 1); j++) putchar('#'); putchar('\n'); } void diamond(int n) { if (n <= 0) { return; } unsigned int i; for (i = 1; i <= n; i++) { d_line(i, n); } for (i = n-1; i > 0; i--) { d_line(i, n); } } int main(int argc, char** argv) { if (argc != 2) { fprintf(stderr, "Usage: %s [side]\n", argv[0]); return 1; } diamond(atoi(argv[1])); }