Skip to content

Instantly share code, notes, and snippets.

@hxmwr
Last active May 3, 2020 12:57
Show Gist options
  • Save hxmwr/a54abe1452b5e6942820fe3536492469 to your computer and use it in GitHub Desktop.
Save hxmwr/a54abe1452b5e6942820fe3536492469 to your computer and use it in GitHub Desktop.
print diamond pattern
#include <stdio.h>
int main()
{
char *str = " ************";
for (int i = 0 i < 20; i++) printf("%.*s\n", i/4%2==0?i % 4 + 5:9-i%4, i/4%2==0?str + i % 4:str+4-i%4);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment