Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Calculate how to display a hand of cards for 80 column console
#include <stdio.h>
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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.