/*
***************************************************************************
*
* Filename: 403.c
*
* Description:
*
* Version: 0.1
* Created: 4/12/2009 5:42:37 PM
*
* Author: Ye Xiaofeng, yexfeng # gmail.com
*
***************************************************************************
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char board[60][6];
char ch_a[5][7] = {
".***..",
"*...*.",
"*****.",
"*...*.",
"*...*."
};
char ch_b[5][7] = {
"****..",
"*...*.",
"****..",
"*...*.",
"****.."
};
char ch_c[5][7] = {
".****.",
"*...*.",
"*.....",
"*.....",
".****."
};
char ch_d[5][7] = {
"****..",
"*...*.",
"*...*.",
"*...*.",
"****.."
};
char ch_e[5][7] = {
"*****.",
"*.....",
"***...",
"*.....",
"*****."
};
char ch_f[5][7] = {
"*****.",
"*.....",
"***...",
"*.....",
"*....."
};
char ch_g[5][7] = {
".****.",
"*.....",
"*..**.",
"*...*.",
".***.."
};
char ch_h[5][7] = {
"*...*.",
"*...*.",
"*****.",
"*...*.",
"*...*."
};
char ch_i[5][7] = {
"*****.",
"..*...",
"..*...",
"..*...",
"*****."
};
char ch_j[5][7] = {
"..***.",
"...*..",
"...*..",
"*..*..",
".**..."
};
char ch_k[5][7] = {
"*...*.",
"*..*..",
"***...",
"*..*..",
"*...*."
};
char ch_l[5][7] = {
"*.....",
"*.....",
"*.....",
"*.....",
"*****."
};
char ch_m[5][7] = {
"*...*.",
"**.**.",
"*.*.*.",
"*...*.",
"*...*."
};
char ch_n[5][7] = {
"*...*.",
"**..*.",
"*.*.*.",
"*..**.",
"*...*."
};
char ch_o[5][7] = {
".***..",
"*...*.",
"*...*.",
"*...*.",
".***.."
};
char ch_p[5][7] = {
"****..",
"*...*.",
"****..",
"*.....",
"*....."
};
char ch_q[5][7] = {
".***..",
"*...*.",
"*...*.",
"*..**.",
".****."
};
char ch_r[5][7] = {
"****..",
"*...*.",
"****..",
"*..*..",
"*...*."
};
char ch_s[5][7] = {
".****.",
"*.....",
".***..",
"....*.",
"****.."
};
char ch_t[5][7] = {
"*****.",
"*.*.*.",
"..*...",
"..*...",
".***.."
};
char ch_u[5][7] = {
"*...*.",
"*...*.",
"*...*.",
"*...*.",
".***.."
};
char ch_v[5][7] = {
"*...*.",
"*...*.",
".*.*..",
".*.*..",
"..*..."
};
char ch_w[5][7] = {
"*...*.",
"*...*.",
"*.*.*.",
"**.**.",
"*...*."
};
char ch_x[5][7] = {
"*...*.",
".*.*..",
"..*...",
".*.*..",
"*...*."
};
char ch_y[5][7] = {
"*...*.",
".*.*..",
"..*...",
"..*...",
"..*..."
};
char ch_z[5][7] = {
"*****.",
"...*..",
"..*...",
".*....",
"*****."
};
char ch_blank[5][7] = {
"......",
"......",
"......",
"......",
"......"
};
char *c5_ch_array[26] = {
(char*)ch_a, (char*)ch_b, (char*)ch_c, (char*)ch_d, (char*)ch_e, (char*)ch_f,
(char*)ch_g, (char*)ch_h, (char*)ch_i, (char*)ch_j, (char*)ch_k, (char*)ch_l,
(char*)ch_m, (char*)ch_n, (char*)ch_o, (char*)ch_p, (char*)ch_q, (char*)ch_r,
(char*)ch_s, (char*)ch_t, (char*)ch_u, (char*)ch_v, (char*)ch_w, (char*)ch_y,
(char*)ch_z
};
void c5_print_ch(int row, int col, char ch);
void c5_print(int row, int col, int ali, char *str);
void c1_print(int row, int col, int ali, char *str);
void c5_print_ch(int row, int col, char ch)
{
char *c5_ch = NULL;
int r, c = 0;
if (' ' == ch) {
c5_ch = (char*)ch_blank;
} else {
c5_ch = (char*)c5_ch_array[ch-'A'];
}
for (r = 0; r < 5; r++) {
if (r < 0 || r >= 60) {
continue;
}
for (c = 0; c < 6; c++) {
if (c < 0 || c >= 60) {
continue;
}
board[row+r][col+c] = *(c5_ch+(r*6+c));
}
}
}
int main(int argc, char **argv)
{
char pos[5];
char font[3];
int row;
int col;
char str[70];
int i, j = 0;
scanf("%s", &pos);
while (0 != strcmp(pos, ".EOP")) {
scanf("%s", &font);
scanf("%d", &row);
if (pos[1] == 'P') {
scanf("%d", &col);
}
scanf("%s", &str);
str[strlen(str)] = '\0';
if ('5' == font[1]) {
c5_print(row, col, pos[1], str+1);
} else {
c1_print(row, col, pos[1], str+1);
}
}
for (i = 0; i < 60; i++) {
for (j = 0; j < 60; j++) {
printf("%c", board[i][j]);
}
printf("\n");
}
}
void c5_print(int row, int col, char ali, char *str)
{
int real_col = 0;
int str_len = strlen(str);
int i = 0;
switch (ali) {
case 'c':
real_col = 30 - (6*str_len)/2;
break;
case 'P':
real_col = col;
break;
case 'L':
real_col = 0;
break;
case 'R':
real_col = 60 - str_len*6;
break;
}
for (i = 0; i < str_len; i++) {
c5_print_ch(row, real_col, str[i]);
real_col += 6;
}
}
void c1_print(int row, int col, int ali, char *str)
{
int str_len = 0;
int real_col = 0;
int i = 0;
str_len = strlen(str);
switch (ali) {
case 'C':
real_col = 31 - str_len/2;
break;
case 'P':
real_col = col;
break;
case 'R':
real_col = 60 - str_len;
break;
case 'L':
break;
}
for (i = 0; i < str_len; i++) {
board[row][real_col+i] = str[i];
}
}
|