Skip to content

Instantly share code, notes, and snippets.

@Abreto
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save Abreto/95b8dbdb3f96a22d9898 to your computer and use it in GitHub Desktop.

Select an option

Save Abreto/95b8dbdb3f96a22d9898 to your computer and use it in GitHub Desktop.
UVa 706 - 液晶显示屏{LC-Display}
/* Programming Challenges 110104 - LC-Display */
#include <stdio.h>
#include <string.h>
const char cdigits[10][5][3] = {
{
{' ','-',' '},
{'|',' ','|'},
{' ',' ',' '},
{'|',' ','|'},
{' ','-',' '}
}, /* 0 */
{
{' ',' ',' '},
{' ',' ','|'},
{' ',' ',' '},
{' ',' ','|'},
{' ',' ',' '}
}, /* 1 */
{
{' ','-',' '},
{' ',' ','|'},
{' ','-',' '},
{'|',' ',' '},
{' ','-',' '}
}, /* 2 */
{
{' ','-',' '},
{' ',' ','|'},
{' ','-',' '},
{' ',' ','|'},
{' ','-',' '}
}, /* 3 */
{
{' ',' ',' '},
{'|',' ','|'},
{' ','-',' '},
{' ',' ','|'},
{' ',' ',' '}
}, /* 4 */
{
{' ','-',' '},
{'|',' ',' '},
{' ','-',' '},
{' ',' ','|'},
{' ','-',' '}
}, /* 5 */
{
{' ','-',' '},
{'|',' ',' '},
{' ','-',' '},
{'|',' ','|'},
{' ','-',' ',}
}, /* 6 */
{
{' ','-',' '},
{' ',' ','|'},
{' ',' ',' '},
{' ',' ','|'},
{' ',' ',' '}
}, /* 7 */
{
{' ','-',' '},
{'|',' ','|'},
{' ','-',' '},
{'|',' ','|'},
{' ','-',' '}
}, /* 8 */
{
{' ','-',' '},
{'|',' ','|'},
{' ','-',' '},
{' ',' ','|'},
{' ','-',' '}
} /* 9 */
};
int main(void)
{
int i = 0, j = 0, k = 0, l = 0, m = 0;
int s = 0;
char n[10] = {0};
int nloopr[5] = {1,0,1,0,1};
int nloopc[3] = {1,0,1};
while( EOF != scanf("%d %s", &s, n) )
{
int ndigit = 0;
int digits[10] = {0};
if( 0==s )
break;
/* convert s to ds */
ndigit = strlen(n);
for(i = 0;i < ndigit;++i)
digits[i] = n[i]-'0';
nloopr[1] = nloopr[3] = s;
nloopc[1] = s;
for(i = 0;i < 5;++i) /* row part */
{
for(l = 0;l < nloopr[i];++l)
{
int nnums = 0;
for(j = 0;j < ndigit;++j) /* handle every number */
{
nnums ++;
if( nnums > 1 )
printf(" ");
for(k =0;k < 3;++k) /* col part */
for(m = 0;m < nloopc[k];++m)
printf("%c", cdigits[digits[j]][i][k]);
}
printf("\n");
}
}
printf("\n");
memset(n, 0, sizeof(n));
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment