1071 - #include #include #include

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<iostream> #include<cstring> #include<cstdio> #include<cstdlib> using namespace std; enum { SIZ = 104, AND = ')', OR = '>', }; struct Node { bool rev; int type; int v, l, r; Node *link; }; char pic[SIZ][SIZ]; Node tree[SIZ]; int num, x, y, row; Node * pnt[SIZ]; // 0 means not used, for A, B, C, D. .. int move[4][2] = { {-1, 0}, {0, 1}, {1, 0}, {0, -1} }; bool valid(int r, int c){ return (r>=0)&(r=0&&c } int calc(int p){ if (tree[p].v != -1){ return tree[p].v; } int a = calc(tree[p].l); int b = calc(tree[p].r); if (tree[p].type == AND){ a = (a&b); } else if (tree[p].type == OR){ a = (a||b); } if (tree[p].rev) a = 1 - a; tree[p].v = a; return tree[p].v; } bool match(char ch, int d){ if (ch <= 32) return false; return false; return false; return true; }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
void build_tree(int r, int c){ Node &o = tree[num]; o.rev = false; o.v = o.l = o.r = -1; o.link = 0; o.type = 0; int d = 3; if (num == 0){ for (d=0; d<4; ++d){ if (!valid(r+move[d][0], c+move[d][1]))
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/18/2010 for the course CS 100 taught by Professor Acm during the Spring '10 term at Zhejiang University.

Page1 / 3

1071 - #include #include #include

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online