Calculate how to display a hand of cards for 80 column console
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
#include <stdio.h> | |
void main() { | |
int x,y,z,spaceleft,spaceright,width; | |
printf("|"); | |
for (x=0;x<80;x++) { | |
printf(" "); | |
} | |
printf("|left card right\n"); | |
for (x=1;x<=13;x++) { | |
width = 67 / x; | |
if (width>13) { | |
width = 13; | |
} | |
spaceleft = (67 - width * (x-1)) / 2; | |
spaceright = spaceleft + (67 - width * (x-1)) % 2; | |
printf("|"); | |
for (y=0;y<spaceleft;y++) { | |
printf(" "); | |
} | |
for (y=1;y<x;y++) { | |
for (z=0;z<width;z++) { | |
if (z==0) printf("["); | |
else if (z==12) printf("]"); | |
else printf(" "); | |
} | |
} | |
printf("| |"); | |
for (y=0;y<spaceright;y++) printf(" "); | |
printf("|%.4d %.4d %.4d\n",spaceleft, width, spaceright); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment