Advertisement
Plabon_dutta

UVA 706 - LC-Display

Aug 9th, 2021
604
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.92 KB | None | 0 0
  1. #include<stdio.h>
  2. #define MAX 1000
  3. void print(char table[][MAX],char c,int s,int x){
  4.     int row,cul;   
  5.     for(cul=x;cul<=x+s+1;cul++)
  6.         for(row=0;row<=2*s+2;row++)
  7.             if(cul==x||cul==x+s+1)
  8.                 if((row>=1&&row<=s)||(row>=s+2&&row<=2*s+1))
  9.                     table[row][cul]='|';
  10.                 else
  11.                     table[row][cul]=' ';
  12.             else
  13.                 if((row>=1&&row<=s)||(row>=s+2&&row<=2*s+1))
  14.                     table[row][cul]=' ';
  15.                 else
  16.                     table[row][cul]='-';
  17.     switch(c){
  18.     case '0':
  19.         for(cul=x+1;cul<=x+s;cul++)
  20.             table[s+1][cul]=' ';
  21.         break;
  22.     case '1':
  23.         for(row=1;row<=2*s+2;row++)
  24.             table[row][x]=' ';
  25.         for(cul=x+1;cul<=x+s;cul++)
  26.             table[0][cul]=table[s+1][cul]=table[2*s+2][cul]=' ';
  27.         break;
  28.     case '2':
  29.         for(row=1;row<=s;row++)
  30.             table[row][x]=' ';
  31.         for(row=s+2;row<=2*s+1;row++)
  32.             table[row][x+s+1]=' ';
  33.         break;
  34.     case '3':
  35.         for(row=1;row<=2*s+1;row++)
  36.             table[row][x]=' ';
  37.         break;
  38.     case '4':
  39.         for(cul=x;cul<=x+s+1;cul++)
  40.             table[0][cul]=table[2*s+2][cul]=' ';
  41.         for(row=s+2;row<=2*s+1;row++)
  42.             table[row][x]=' ';
  43.         break;
  44.     case '5':
  45.         for(row=1;row<=s;row++)
  46.             table[row][x+s+1]=' ';
  47.         for(row=s+2;row<=2*s+1;row++)
  48.             table[row][x]=' ';
  49.         break;
  50.     case '6':
  51.         for(row=1;row<=s;row++)
  52.             table[row][x+s+1]=' ';
  53.         break;
  54.     case '7':
  55.         for(row=1;row<=2*s+1;row++)
  56.             table[row][x]=' ';
  57.         for(cul=x+1;cul<=x+s;cul++)
  58.             table[s+1][cul]=table[2*s+2][cul]=' ';
  59.         break;
  60.     case '8':
  61.         break;
  62.     case '9':
  63.         for(row=s+2;row<=2*s+1;row++)
  64.             table[row][x]=' ';
  65.         break;
  66.     }
  67.     for(row=0;row<=2*s+2;row++)
  68.         table[row][x+s+2]=' ';
  69. }
  70. int main(){
  71.     int s;
  72.     char str[100];
  73.     while(scanf("%d%s",&s,str)==2){
  74.         if(s==0&&(str[0]=='0'&&str[1]=='\0'))
  75.             break;
  76.         char table[30][MAX];
  77.         int row,cul=0;
  78.         for(int i=0;str[i]!='\0';i++){
  79.             print(table,str[i],s,cul);
  80.             cul+=s+3;
  81.         }
  82.         for(row=0,cul--;row<=2*s+2;row++)
  83.             table[row][cul]='\0';
  84.         for(int i=0;i<=2*s+2;i++)
  85.             printf("%s\n",table[i]);
  86.         putchar('\n');
  87.     }
  88.     return 0;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement