又是模拟题,用c++类乱搞一通
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
char **ans;
struct Base
{
int height, width, middle;
Base *father, *next, *last;
Base(Base *fa);
virtual string is() = 0;
virtual void calcSize() = 0;
virtual void draw(int x, int y) = 0;
};
struct Space: public Base
{
Space(Base *fa);
virtual string is();
virtual void calcSize();
virtual void draw(int x, int y);
};
struct Char: public Base
{
char data;
Char(Base *fa, char c);
virtual string is();
virtual void calcSize();
virtual void draw(int x, int y);
};
struct Edit: public Base
{
Base *head, *tail;
Edit(Base *fa);
virtual string is();
virtual void calcSize();
virtual void draw(int x, int y);
};
struct Frac: public Base
{
Edit *up, *down;
Frac(Base *fa);
virtual string is();
virtual void calcSize();
virtual void draw(int x, int y);
};
struct Matrix: public Base
{
Edit ** *data;
int n, m;
Matrix(Base *fa);
virtual string is();
virtual void calcSize();
virtual void draw(int x, int y);
void FindPos(Edit *pos, int &x, int &y);
Space *AddRow(Edit *pos);
Space *AddCol(Edit *pos);
};
string Space::is()
{
return "Space";
}
string Char::is()
{
return "Char";
}
string Frac::is()
{
return "Frac";
}
string Matrix::is()
{
return "Matrix";
}
string Edit::is()
{
return "Edit";
}
void Space::calcSize()
{
height = 1;
middle = 0;
width = 0;
}
void Char::calcSize()
{
height = 1;
middle = 0;
if (data == '-')
width = 3;
else
width = 1;
}
void Frac::calcSize()
{
height = up->height + down->height + 1;
width = max(up->width, down->width) + 2;
middle = up->height;
}
void Matrix::calcSize()
{
int *h = new int[n];
for (int i = 0; i < n; ++i)
{
Edit *hh = data[i][0];
for (int j = 1; j < m; ++j)
if (hh->middle < data[i][j]->middle)
hh = data[i][j];
h[i] = 1;
for (int j = 0; j < m; ++j)
h[i] = max(h[i], data[i][j]->height - data[i][j]->middle);
h[i] += hh->middle;
}
height = n - 1;
for (int i = 0; i < n; ++i)
height += h[i];
width = 2 + m - 1;
for (int i = 0; i < m; ++i)
{
int tmp = 0;
for (int j = 0; j < n; ++j)
tmp = max(tmp, data[j][i]->width);
width += tmp;
}
middle = 0;
for (int i = 0; i < n / 2; ++i)
middle += h[i];
if (n % 2)
{
middle += n / 2;
int hh = 0;
for (int j = 1; j < m; ++j)
if (data[n / 2][hh]->middle < data[n / 2][j]->middle)
hh = j;
middle += data[n / 2][hh]->middle;
}
else
middle += n / 2 - 1;
delete[] h;
}
void Edit::calcSize()
{
width = 0;
Base *hh = head;
for (Base *i = head; i; i = i->next)
if (hh->middle < i->middle)
hh = i;
middle = hh->middle;
height = 1;
for (Base *i = head; i; i = i->next)
{
height = max(height, i->height - i->middle);
width += i->width;
}
height += middle;
}
Base::Base(Base *fa): father(fa), next(NULL), last(NULL) {}
Space::Space(Base *fa): Base(fa)
{
calcSize();
}
Char::Char(Base *fa, char c): Base(fa), data(c)
{
calcSize();
}
Frac::Frac(Base *fa): Base(fa)
{
up = new Edit(this);
down = new Edit(this);
calcSize();
}
Matrix::Matrix(Base *fa): Base(fa), n(1), m(1)
{
data = new Edit **[1];
data[0] = new Edit*[1];
data[0][0] = new Edit(this);
calcSize();
}
Edit::Edit(Base *fa): Base(fa)
{
head = tail = new Space(this);
calcSize();
}
void Matrix::FindPos(Edit *pos, int &x, int &y)
{
for (int i = 0; i < n; ++i)
for (int j = 0; j < m; ++j)
if (data[i][j] == pos)
{
x = i, y = j;
return;
}
}
Space *Matrix::AddRow(Edit *pos)
{
int x, y;
FindPos(pos, x, y);
Edit ***ndata = new Edit **[n + 1];
for (int i = 0; i <= n; ++i)
ndata[i] = new Edit*[m];
for (int i = 0; i <= n; ++i)
for (int j = 0; j < m; ++j)
if (i == x)
ndata[i][j] = new Edit(this);
else
ndata[i][j] = data[i < x ? i : i - 1][j];
++n;
data = ndata;
calcSize();
return (Space *)data[x][y]->head;
}
Space *Matrix::AddCol(Edit *pos)
{
int x, y;
FindPos(pos, x, y);
Edit ***ndata = new Edit **[n];
for (int i = 0; i < n; ++i)
ndata[i] = new Edit*[m + 1];
for (int i = 0; i < n; ++i)
for (int j = 0; j <= m; ++j)
if (j == y)
ndata[i][j] = new Edit(this);
else
ndata[i][j] = data[i][j < y ? j : j - 1];
++m;
data = ndata;
calcSize();
return (Space *)data[x][y]->head;
}
void Space::draw(int x, int y) {}
void Char::draw(int x, int y)
{
if (data == '-')
ans[x][y] = ' ', ans[x][y + 1] = '-', ans[x][y + 2] = ' ';
else
ans[x][y] = data;
}
void Edit::draw(int x, int y)
{
for (Base *i = head; i; i = i->next)
{
i->draw(x, y);
y += i->width;
}
}
void Frac::draw(int x, int y)
{
up->draw(x - (up->height - up->middle) , y + (width - up->width) / 2);
for (int i = 0; i < width; ++i)
ans[x][y + i] = '-';
down->draw(x + down->middle + 1, y + (width - down->width) / 2);
}
void Matrix::draw(int x, int y)
{
int *w = new int[m], *h = new int[n], *mid = new int[n];
for (int i = 0; i < m; ++i)
{
w[i] = 0;
for (int j = 0; j < n; ++j)
w[i] = max(w[i], data[j][i]->width);
}
for (int i = 0; i < n; ++i)
{
Edit *hh = data[i][0];
for (int j = 1; j < m; ++j)
if (hh->middle < data[i][j]->middle)
hh = data[i][j];
mid[i] = hh->middle;
h[i] = 1;
for (int j = 0; j < m; ++j)
h[i] = max(h[i], data[i][j]->height - data[i][j]->middle);
h[i] += hh->middle;
}
int h1, h2;
if (n % 2)
{
ans[x][y] = '[';
int y2 = y + 1;
for (int i = 0; i < m; ++i)
{
data[n / 2][i]->draw(x, y2 + (w[i] - data[n / 2][i]->width) / 2);
y2 += w[i] + 1;
}
ans[x][y + width - 1] = ']';
h1 = mid[n / 2] + 1, h2 = h[n / 2] - mid[n / 2];
}
else
h1 = h2 = 0;
for (int i = n / 2 - 1; i >= 0; --i)
{
++h1;
int x2 = x - h1 - (h[i] - mid[i] - 1);
int y2 = y + 1;
ans[x2][y] = '[';
for (int j = 0; j < m; ++j)
{
data[i][j]->draw(x2, y2 + (w[j] - data[i][j]->width) / 2);
y2 += w[j] + 1;
}
ans[x2][y + width - 1] = ']';
h1 += h[i];
}
for (int i = n / 2 + n % 2; i < n; ++i)
{
++h2;
int x2 = x + h2 + mid[i];
int y2 = y + 1;
ans[x2][y] = '[';
for (int j = 0; j < m; ++j)
{
data[i][j]->draw(x2, y2 + (w[j] - data[i][j]->width) / 2);
y2 += w[j] + 1;
}
ans[x2][y + width - 1] = ']';
h2 += h[i];
}
delete[] w;
delete[] h;
}
Space *cur;
void CurHome()
{
cur = (Space *)((Edit *)cur->father)->head;
}
void CurEnd()
{
cur = (Space *)((Edit *)cur->father)->tail;
}
void CurLeft()
{
if (cur->last == NULL)
{
Edit *f = (Edit *)cur->father;
if (f->father && f->father->is() == "Matrix")
{
int x, y;
((Matrix *)f->father)->FindPos(f, x, y);
if (y)
{
cur = (Space *)((Matrix *)f->father)->data[x][y - 1]->tail;
return;
}
}
if (f->father)
cur = (Space *)f->father->last;
}
else if (cur->last->is() == "Frac")
cur = (Space *)((Frac *)cur->last)->up->tail;
else if (cur->last->is() == "Matrix")
{
Matrix *l = (Matrix *)cur->last;
cur = (Space *)l->data[(l->n - 1) / 2][l->m - 1]->tail;
}
else
cur = (Space *)cur->last->last;
}
void CurRight()
{
if (cur->next == NULL)
{
Edit *f = (Edit *)cur->father;
if (f->father && f->father->is() == "Matrix")
{
int x, y;
((Matrix *)f->father)->FindPos(f, x, y);
if (y + 1 != ((Matrix *)f->father)->m)
{
cur = (Space *)((Matrix *)f->father)->data[x][y + 1]->head;
return;
}
}
if (f->father)
cur = (Space *)f->father->next;
}
else if (cur->next->is() == "Frac")
cur = (Space *)((Frac *)cur->next)->up->head;
else if (cur->next->is() == "Matrix")
{
Matrix *n = (Matrix *)cur->next;
cur = (Space *)n->data[(n->n - 1) / 2][0]->head;
}
else
cur = (Space *)cur->next->next;
}
void CurUp()
{
Space *cur2 = cur;
while (cur2->father->father)
{
Edit *f = (Edit *)cur2->father;
if (f->father->is() == "Frac" && f == ((Frac *)f->father)->down)
{
cur = (Space *)((Frac *)f->father)->up->head;
return;
}
if (f->father->is() == "Matrix")
{
Matrix *ff = (Matrix *)f->father;
int x, y;
ff->FindPos(f, x, y);
if (x)
{
cur = (Space *)ff->data[x - 1][y]->head;
return;
}
}
if (f->father->father == NULL)
return;
cur2 = (Space *)((Edit*)f->father->father)->head;
}
}
void CurDown()
{
Space *cur2 = cur;
while (cur2->father->father)
{
Edit *f = (Edit *)cur2->father;
if (f->father->is() == "Frac" && f == ((Frac *)f->father)->up)
{
cur = (Space *)((Frac *)f->father)->down->head;
return;
}
if (f->father->is() == "Matrix")
{
Matrix *ff = (Matrix *)f->father;
int x, y;
ff->FindPos(f, x, y);
if (x + 1 != ff->n)
{
cur = (Space *)ff->data[x + 1][y]->head;
return;
}
}
if (f->father->father == NULL)
return;
cur2 = (Space *)((Edit*)f->father->father)->head;
}
}
void CurInsert(Base *ins)
{
Space *ncur = new Space(cur->father);
if (cur->next)
cur->next->last = ncur;
ncur->next = cur->next;
ncur->last = ins;
ins->next = ncur;
ins->last = cur;
cur->next = ins;
Base *&i = ((Edit *)cur->father)->tail;
while (i->next)
i = i->next;
for (Base *p = cur; p; p = p->father)
p->calcSize();
CurRight();
}
void CurAddRow()
{
for (Base *p = cur; p->father; p = p->father)
if (p->father->is() == "Matrix")
{
cur = ((Matrix *)p->father)->AddRow((Edit *)p);
break;
}
for (Base *p = cur; p; p = p->father)
p->calcSize();
}
void CurAddCol()
{
for (Base *p = cur; p->father; p = p->father)
if (p->father->is() == "Matrix")
{
cur = ((Matrix *)p->father)->AddCol((Edit *)p);
break;
}
for (Base *p = cur; p; p = p->father)
p->calcSize();
}
Edit *root;
int main()
{
root = new Edit(NULL);
cur = (Space *)root->head;
char op[10];
while (scanf("%s", op) != EOF)
if (op[1] == '\0')
CurInsert(new Char(cur->father, op[0]));
else if (strcmp(op, "Matrix") == 0)
CurInsert(new Matrix(cur->father));
else if (strcmp(op, "Fraction") == 0)
CurInsert(new Frac(cur->father));
else if (strcmp(op, "AddRow") == 0)
CurAddRow();
else if (strcmp(op, "AddCol") == 0)
CurAddCol();
else if (strcmp(op, "Home") == 0)
CurHome();
else if (strcmp(op, "End") == 0)
CurEnd();
else if (strcmp(op, "Left") == 0)
CurLeft();
else if (strcmp(op, "Right") == 0)
CurRight();
else if (strcmp(op, "Up") == 0)
CurUp();
else if (strcmp(op, "Down") == 0)
CurDown();
ans = new char *[root->height];
for (int i = 0; i < root->height; ++i)
{
ans[i] = new char[root->width];
memset(ans[i], 0, sizeof(char) * root->width);
}
root->draw(root->middle, 0);
for (int i = 0; i < root->height; ++i)
{
string s;
bool hv = false;
for (int j = root->width - 1; j >= 0; --j)
{
hv = hv || ans[i][j];
if (hv)
s += (ans[i][j] ? ans[i][j] : ' ');
}
reverse(s.begin(), s.end());
while (s.length() && *s.rbegin() == ' ')
s = s.substr(0, s.length() - 1);
printf("%s\n", s.c_str());
}
return 0;
}
在BZOJ上各种PE,原因是题目里说减号两边应有空格,而数据里没有行末空格
此题CTSC数据包里的标程编译不过,要改改才能用,而且还有bug!!!
贴一下错误的标程
#include <string>
#include <cstring>
#include <fstream>
#include <iostream>
#include <memory>
using namespace std;
const int
CUp = 0,
CDown = 1,
CLeft = 2,
CRight = 3,
CHome = 4,
CEnd = 5;
const int
TBase = 0,
TExpFrame = 1,
TFraction = 2,
TMatrix = 3;
char* strins(char* src, char* insstr)
{
int sl = strlen(insstr);
for (int i = strlen(src); i >= 0; i--)
src[i+sl] = src[i];
return strncpy(src, insstr, sl);
}
class Base
{
public:
static Base *CursorExp;
int w, h, AlignLine;
char **Content;
int ClassType;
Base *Owner;
Base()
{
ClassType = TBase;
w = 0;
h = 1;
AlignLine = 0;
Content = NULL;
Owner = NULL;
}
~Base()
{
DeleteContent();
}
virtual void MoveCursor(int Dir) // in the inner or to the outer
{
}
virtual void PassCursor(int Dir) // from outer to inner
{
}
virtual char** Format()
{
return Content;
}
void NewContent()
{
Content = new char*[h];
for (int iy = 0; iy < h; iy++)
{
Content[iy] = new char[w+2];
memset(Content[iy], 32, w);
Content[iy][w] = 0;
Content[iy][w+1] = 0;
}
}
void DeleteContent()
{
if (Content != NULL)
{
for (int iy = 0; iy < h; iy++)
delete Content[iy];
delete Content;
Content = NULL;
}
}
void PutExp(int x, int y, Base *E)
{
for (int iy = 0; iy < E->h; iy++)
memcpy(Content[iy+y] + x, E->Content[iy],strlen(E->Content[iy]));
}
};
class ExpFrame: public Base
{
public:
int CurPos;
ExpFrame(int len=500)
{
ClassType = TExpFrame;
Express = new char[len];
Express[0] = 0;
CurPos = 0;
ind = 0;
}
~ExpFrame()
{
delete Express;
}
void InsElement(char *str);
void PassCursor(int Dir)
{
CursorExp = this;
if (Dir == CLeft)
CurPos = strlen(Express);
else
CurPos = 0;
}
void MoveCursor(int Dir)
{
switch (Dir)
{
case CUp:
case CDown:
if (Owner != NULL)
Owner->MoveCursor(Dir);
break;
case CLeft:
if (CurPos > 0)
{
CurPos--;
if (Express[CurPos] < 32)
NonStr[Express[CurPos] - 1]->PassCursor(Dir);
}
else
if (Owner != NULL)
Owner->MoveCursor(Dir);
break;
case CRight:
if (Express[CurPos])
{
if (Express[CurPos] < 32)
NonStr[Express[CurPos] - 1]->PassCursor(Dir);
else
CurPos++;
}
else
if (Owner != NULL)
Owner->MoveCursor(Dir);
break;
case CHome:
CurPos = 0;
break;
case CEnd:
CurPos = strlen(Express);
break;
}
}
char** Format()
{
DeleteContent();
int len = strlen(Express);
int hup = 0, hdown = 1;
w = 0;
for (int i = 0; i < len; i++)
if (Express[i] < 32)
{
int idns = Express[i]-1;
NonStr[idns]->Format();
if (NonStr[idns]->AlignLine > hup)
hup = NonStr[idns]->AlignLine;
if (NonStr[idns]->h - NonStr[idns]->AlignLine > hdown)
hdown = NonStr[idns]->h - NonStr[idns]->AlignLine;
w+=NonStr[idns]->w;
}
else
{
if (Express[i] == '-')
w += 3;
else
w++;
}
h = hup + hdown;
AlignLine = hup;
NewContent();
int x = 0;
for (int i = 0; i < len; i++)
{
if (Express[i] < 32)
{
int idns = Express[i]-1;
PutExp(x, hup - NonStr[idns]->AlignLine, NonStr[idns]);
x+=NonStr[idns]->w;
}
else
if (Express[i] == '-')
{
Content[hup][x+1] = '-';
x += 3;
}
else
Content[hup][x++] = Express[i];
}
return Content;
}
protected:
int ind;
char* Express;
Base* NonStr[30];
};
class Fraction: public Base
{
public:
Fraction()
{
ClassType = TFraction;
num = new ExpFrame();
num->Owner = this;
den = new ExpFrame();
den->Owner = this;
}
~Fraction()
{
delete num;
delete den;
}
void MoveCursor(int Dir)
{
switch (Dir)
{
case CUp:
if (CurExp == den)
{
CurExp = num;
num->PassCursor(Dir);
}
else
if (Owner != NULL)
Owner->MoveCursor(Dir);
break;
case CDown:
if (CurExp == num)
{
CurExp = den;
den->PassCursor(Dir);
}
else
if (Owner != NULL)
Owner->MoveCursor(Dir);
break;
case CLeft:
CursorExp = Owner;
break;
case CRight:
CursorExp = Owner;
((ExpFrame*)Owner)->CurPos++;
}
}
void PassCursor(int Dir)
{
CurExp = num;
num->PassCursor(Dir);
}
char** Format()
{
DeleteContent();
num->Format();
den->Format();
if (num->w > den->w)
w = num->w;
else
w = den->w;
w+=2;
h = num->h + den->h + 1;
AlignLine = num->h;
NewContent();
PutExp((w - num->w)/2, 0, num);
memset(Content[AlignLine], '-', w);
PutExp((w - den->w)/2, num->h+1, den);
return Content;
}
protected:
ExpFrame *CurExp, *num, *den;
};
class Matrix: public Base
{
public:
Matrix(int r, int c)
{
ClassType = TMatrix;
ew = r; eh = c;
for (int iy = 0; iy < eh; iy++)
for (int ix = 0; ix < ew; ix++)
{
Cell[iy][ix] = new ExpFrame();
Cell[iy][ix]->Owner = this;
}
}
~Matrix()
{
for (int iy = 0; iy < eh; iy++)
for (int ix = 0; ix < ew; ix++)
delete Cell[iy][ix];
}
void PassCursor(int Dir)
{
if (Dir == CLeft)
{
cy = (eh-1)/2;
cx = ew-1;
}
else
{
cy = (eh-1)/2;
cx = 0;
}
Cell[cy][cx]->PassCursor(Dir);
}
void MoveCursor(int Dir)
{
switch (Dir)
{
case CUp:
if (cy > 0)
{
cy--;
Cell[cy][cx]->PassCursor(Dir);
}
else
if (Owner != NULL)
Owner->MoveCursor(Dir);
break;
case CDown:
if (cy < eh-1)
{
cy++;
Cell[cy][cx]->PassCursor(Dir);
}
else
if (Owner != NULL)
Owner->MoveCursor(Dir);
break;
case CLeft:
if (cx > 0)
{
cx--;
Cell[cy][cx]->PassCursor(Dir);
}
else
CursorExp = Owner;
break;
case CRight:
if (cx < ew-1)
{
cx++;
Cell[cy][cx]->PassCursor(Dir);
}
else
{
CursorExp = Owner;
((ExpFrame*)Owner)->CurPos++;
}
}
}
char** Format()
{
DeleteContent();
int ix, iy;
int hup[10], hdown[10], wmax[10];
memset(hup, 0, sizeof(hup));
memset(hdown, 0, sizeof(hdown));
memset(wmax, 0, sizeof(wmax));
for (iy = 0; iy < eh; iy++)
for (ix = 0; ix < ew; ix++)
{
Cell[iy][ix]->Format();
if (wmax[ix] < Cell[iy][ix]->w)
wmax[ix] = Cell[iy][ix]->w;
if (hup[iy] < Cell[iy][ix]->AlignLine)
hup[iy] = Cell[iy][ix]->AlignLine;
if (hdown[iy] < Cell[iy][ix]->h - Cell[iy][ix]->AlignLine)
hdown[iy] = Cell[iy][ix]->h - Cell[iy][ix]->AlignLine;
}
w = 1;
for (ix = 0; ix < ew; ix++)
w += (wmax[ix] + 1);
h = 0;
for (iy = 0; iy < eh; iy++)
h += (hup[iy] + hdown[iy] + 1);
h--;
AlignLine = 0;
for (iy = 0; iy < eh / 2; iy++)
AlignLine += (hup[iy] + hdown[iy] + 1);
if (eh&1)
AlignLine += hup[eh/2];
else
AlignLine --;
NewContent();
int x, y = 0;
for (iy = 0; iy < eh; y += (hup[iy]+hdown[iy]+1), iy++)
{
x = 1;
Content[y+hup[iy]][0] = '[';
Content[y+hup[iy]][w-1] = ']';
for (ix = 0; ix < ew; x += (wmax[ix]+1), ix++)
PutExp(x + (wmax[ix]-Cell[iy][ix]->w)/2, y + hup[iy]-Cell[iy][ix]->AlignLine, Cell[iy][ix]);
}
return Content;
}
void AddRow()
{
AddRowBefore(cy);
}
void AddCol()
{
AddColBefore(cx);
}
void AddRowBefore(int r)
{
for (int iy = eh-1; iy >= r; iy--)
for (int ix = 0; ix < ew; ix++)
Cell[iy+1][ix] = Cell[iy][ix];
for (int ix = 0; ix < ew; ix++)
{
Cell[r][ix] = new ExpFrame();
Cell[r][ix]->Owner = this;
}
eh++;
Cell[cy][cx]->PassCursor(CLeft);
}
void AddColBefore(int c)
{
for (int iy = 0; iy < eh; iy++)
for (int ix = ew-1; ix >= c; ix--)
Cell[iy][ix+1] = Cell[iy][ix];
for (int iy = 0; iy < eh; iy++)
{
Cell[iy][c] = new ExpFrame();
Cell[iy][c]->Owner = this;
}
ew++;
Cell[cy][cx]->PassCursor(CLeft);
}
protected:
int ew, eh, cx, cy;
ExpFrame* Cell[10][10];
};
void ExpFrame::InsElement(char *str)
{
if (strlen(str) == 1)
{
strins(Express+CurPos, str);
CurPos++;
}
else
{
strins(Express+CurPos, " ");
Express[CurPos] = ind+1;
if (strcmp(str, "Matrix") == 0)
NonStr[ind] = new Matrix(1, 1);
else
if (strcmp(str, "Fraction") == 0)
NonStr[ind] = new Fraction();
NonStr[ind]->Owner = this;
ind++;
MoveCursor(CRight);
}
}
Base* Base::CursorExp = new ExpFrame();
int main()
{
ExpFrame *Global = (ExpFrame*)Base::CursorExp;
while(cin.good())
{
char cmd[80];
cin >> cmd;
if (strlen(cmd )== 0) break;
if (strcmp(cmd, "AddRow") == 0 || strcmp(cmd, "AddCol") == 0)
{
Base* Father = Base::CursorExp;
for (; (Father != NULL) && (Father->ClassType != TMatrix); Father = Father->Owner);
if (Father != NULL)
if (strcmp(cmd, "AddRow")== 0)
((Matrix*)Father)->AddRow();
else
((Matrix*)Father)->AddCol();
}
else
if (strcmp(cmd, "Left") == 0)
Base::CursorExp->MoveCursor(CLeft);
else
if (strcmp(cmd, "Right") == 0)
Base::CursorExp->MoveCursor(CRight);
else
if (strcmp(cmd, "Up") == 0)
Base::CursorExp->MoveCursor(CUp);
else
if (strcmp(cmd, "Down") == 0)
Base::CursorExp->MoveCursor(CDown);
else
if (strcmp(cmd, "Home") == 0)
Base::CursorExp->MoveCursor(CHome);
else
if (strcmp(cmd, "End") == 0)
Base::CursorExp->MoveCursor(CEnd);
else
((ExpFrame*)Base::CursorExp)->InsElement(cmd);
}
Global->Format();
for (int iy = 0; iy < Global->h; iy++)
{
int i;
for(i = strlen(Global->Content[iy])-1; i >= 0 && Global->Content[iy][i] == 32; i--);
Global->Content[iy][i+1] = 0;
cout << Global->Content[iy] << endl;
}
return 0;
}
Matrix
AddRow
AddRow
AddCol
AddCol
1
Right
2
Right
3
Right
Left
6
Left
Left
5
Left
Left
4
Down
7
Right
8
Right
9
此数据应输出
[1 2 3]
[4 5 6]
[7 8 9]
而标程输出
[1 2 3]
[4 5 6]
[7 8 99]