GG
unknown
plain_text
4 years ago
1.7 kB
11
Indexable
Graph::Graph(int m,int n) { M=m; N=n; map = new char*[N+2]; for (int i=0; i<N+2; ++i) { map[i] = new char[M+2]; } for (int i=0; i<N+2; i++) { for (int j=0; j<M+2; j++) { map[i][j] = '0' ; } } for (int i=1; i<N+1; i++) { for (int j=1; j<M+1; j++) { map[i][j] = 'O' ; } } } void Graph::J(char ch) { for (int i=1; i<N+1; i++) { for (int j=1; j<M+1; j++) { map[i][j] = ch; } } } void Graph::C() { for (int i=1; i<N+1; i++) { for (int j=1; j<M+1; j++) { map[i][j] = 'O'; } } } void Graph::L(int x,int y,char c) { map[y][x] = c; } void Graph::V(int x,int y1,int y2,char c) { for (int i=y1; i<=y2; i++) { map[i][x] = c; } } void Graph::H(int x1,int x2,int y,char c) { for (int i=x1; i<=x2; i++) { map[y][i] = c; } } void Graph::K(int x1,int x2,int y1,int y2,char c) { for (int i=x1; i<=x2; i++) { for (int j= y1; j<=y2; j++) { map[j][i] = c; } } } void Graph::F(int x,int y,char c) { char tmp = map[y][x]; map[y][x]=c; if (map[y-1][x-1]==tmp)map[y-1][x-1]=c; if (map[y-1][x]==tmp)map[y-1][x]=c; if (map[y-1][x+1]==tmp)map[y-1][x+1]=c; if (map[y][x-1]==tmp)map[y][x-1]=c; if (map[y][x+1]==tmp)map[y][x+1]=c; if (map[y+1][x-1]==tmp)map[y+1][x-1]=c; if (map[y+1][x]==tmp)map[y+1][x]=c; if (map[y+1][x+1]==tmp)map[y+1][x+1]=c; } void Graph::S(string str) { cout << str << endl; for (int i=1; i<N+1; i++) { for (int j=1; j<M+1; j++) { cout << map[i][j]; } cout << endl; } }
Editor is loading...