Created
August 10, 2012 19:09
-
-
Save 0xAether/3316972 to your computer and use it in GitHub Desktop.
Prints the triforce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* | |
* Triforce | |
* By: Aaron | |
* Started: August 10, 2012 | |
* | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
void printc( long count, char sym ); | |
void printc( long count, char sym ) { | |
long counter; | |
for( counter = 0; counter < count; counter++ ) { | |
putchar( sym ); | |
} | |
} | |
int main(int argc, char *argv[]) { | |
long base, tbase, counter, tlimit, spacecounter, starcounter, ispaces, stars=-1, ospaces; | |
if( argc != 2 ) { | |
exit(1); | |
} | |
if( sscanf( argv[1], "%ld", &base ) != 1 ) { | |
exit(1); | |
} | |
if( base < 7 ) { | |
exit(1); | |
} | |
if( base % 2 == 0 ) { | |
base--; | |
} | |
if( ((base--)/2) % 2 == 0 ) { | |
base += 2; | |
} | |
ospaces=(base--)/2; | |
tbase=ospaces; | |
tlimit=(tbase++)/2; | |
for( counter=0; counter < ospaces; counter++ ) { | |
printc( ospaces, ' ' ); | |
stars += 2; | |
printc( stars, '*' ); | |
printf("\n"); | |
ospaces--; | |
} | |
ispaces=stars; | |
stars=-1; | |
while( (ospaces >= 0) && (ispaces >= 1) ) { | |
printc( ospaces, ' ' ); | |
ospaces--; | |
stars += 2; | |
printc( stars, '*' ); | |
printc( ispaces, ' ' ); | |
ispaces -= 2; | |
printc( stars, '*' ); | |
printf("\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment