Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

也发一个我的代码吧,只有10多行

Posted by Eov_Second at 2016-12-14 14:38:58 on Problem 1102
核心思想也是查表,一个数字有3条横线4条竖线需要控制,这些信息保存在不同的bit位上,这样下来整个表只有5个整数

int g[] = { 1005, 892, 877, 1021867, 768667 }, a, b, n;
char r[114], c, *q, *p, s[12];
void H(int l) {
    for (q = r, p = s; c = *p++; *q++ = 32, *q++ = 32)
        for (*q++ = 32, a = n; a--; *q++ = g[l] & 1 << (c - 48) ? 45 : 32);
    *--q = 0;
    puts(r);
}
void V(int l) {
    for (q = r, p = s; c = *p++; *q++ = g[l + 3] & 1 << b ? 124 : 32, *q++ = 32)
        for (b = 2 * (c - 48), *q++ = g[l + 3] & 1 << b++ ? 124 : 32, a = 0; a++ < n; *q++ = 32);
    *--q = 0;
}
int main(int j) {
    for (; scanf("%d %s", &n, s), n; H(2), puts(""))
        for (j = 2; j--;)
            for (H(1 - j), V(1 - j), a = n; a--; puts(r));
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator