• 自己实现的auto_ptr

    自己实现的auto_ptr,可以实现系统auto_ptr的所有功能,我也组织了一个测试程序,别怪这么贵,原创的!我使用vs2008写的,低版本请您自己配置,运行

    0
    87
    341KB
    2011-03-15
    12
  • 编译原理之词法分析(C源代码)

    除实现的基本的属性字输出外,还附加了如下功能: 1.无符号整型常量合法性的检测 2.标识符作用域的识别 3.未定义标识符的检错 4.括号是否配对的检测 5.支持带小数点的浮点常量 附测试文件及实现要求!

    0
    78
    296KB
    2009-10-22
    9
  • MFC做的C/S聊天系统

    MFC做的C/S聊天系统,内外网调试都没问题,但外网用的在路由设置端口映射

    5
    87
    7.45MB
    2009-09-27
    10
  • PE文件引用库查看器(含源代码)

    PE文件引用库查看器(含源代码),对基于VC等生成非中间字节码的PE文件支持良好,对字节码文件不支持

    5
    83
    4.49MB
    2009-09-06
    9
  • MFC做的windows画图附件

    MFC做的xp画图附件,具有基本的画图功能(方形,椭圆,线条,电子绘图等),皮擦功能可以通过鼠标绘图的线条颜色及线条粗细的设置来达到,绝对原创!

    4
    142
    5.35MB
    2009-09-06
    13
  • 计算器(VC++源代码)

    计算器(VC++源代码),不要觉着简单,自己架构一个试试!

    5
    53
    3.33MB
    2009-06-26
    3
  • c#做的俄罗斯方块,不下后悔

    提供一个核心类,接口仅几个,方便外围开发,你可以在此基础上做一些扩展,如使其界面更美观,方块更美观等 class DyPanel :Panel { #region 类属性 private Timer t_slow,t_fast; private XY current_p, start_p; private XY []cur_square; private XY []afterChange_squar; private int width, height; private SolidBrush bkbrush; private bool [][]ha; private int m, n; private XY [][][]a; private int rotate_outer, rotate_inner; private int outer, inner; private Random ra; private Panel p; private XY reference; private int mark; private Label markl; public char move_flag; private SolidBrush sqbrush; #endregion #region 公有的方法 public DyPanel(Rectangle rf,int width,int height,SolidBrush brush,ref Timer slow,ref Timer fast,Panel p,XY reference,Label markl) { sqbrush = new SolidBrush(Color.FromArgb(150,225,200,12)); this.markl = markl; mark = 0; markl.Text = mark.ToString(); ra = new Random(); this.p = p; this.reference = reference; a=new XY[6][][]; for (int i = 0; i < 6;i++ ) a[i]=new XY[4][]; for (int i = 0; i < 6; i++) { for (int j = 0; j < 4; j++) { a[i][j]=new XY[4]; for (int e = 0; e < 4; e++) a[i][j][e] = new XY(); } } setA(); cur_square=new XY[4]; afterChange_squar=new XY[4]; for (int i = 0; i < 4; i++) { cur_square[i] = new XY(); afterChange_squar[i] = new XY(); } outer = rand(0, 6); inner = rand(0, 4); rotate_outer = outer; rotate_inner = inner; copyXY(a[outer][inner], ref cur_square); outer = rand(0, 6); inner = rand(0, 4); current_p = new XY(); start_p = new XY(); this.width = width; this.height = height; this.bkbrush = brush; this.t_slow = slow; this.t_fast = fast; move_flag = 'p'; this.Size = new Size(rf.Right - rf.Left, rf.Bottom - rf.Top); this.Location = rf.Location; n = (this.ClientRectangle.Right - this.ClientRectangle.Left) / width; m = (this.ClientRectangle.Bottom - this.ClientRectangle.Top) / height; this.start_p.x = n / 2; this.start_p.y = 2; current_p.x = start_p.x; current_p.y = start_p.y; ha = new bool[m][]; for (int i = 0; i < m; i++) { ha[i] = new bool[n]; for (int j = 0; j < n; j++) ha[i][j] = false; } this.BackColor = Color.SlateBlue; this.Paint += new System.Windows.Forms.PaintEventHandler(this.panel_Paint); setTimer(true, false); } public int getMark() { return mark; } public void ReStart() { setTimer(false, false); mark = 0; for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) ha[i][j] = false; current_p.x=start_p.x; current_p.y = start_p.y; mark = 0; markl.Text = mark.ToString(); Logic_Expunction(); Real_Expunction(); } public void draw() { Timer cur_t = t_fast.Enabled ? t_fast : t_slow; cur_t.Enabled = false; XY xy = new XY(); XY []original=new XY[4]; for (int i = 0; i < 4; i++) original[i] = new XY(); if (Square_Move(move_flag, ref xy,ref original)) { if (move_flag != 'w' && move_flag != 'W') { setSelfLogic(cur_square, xy, false, 4); int i; for (i = 0; i < 4; i++) { if (ha[cur_square[i].y - cur_square[0].y + current_p.y][cur_square[i].x - cur_square[0].x + current_p.x]) break; } if(i==4) { draw_square(new SolidBrush(this.BackColor), xy); setSelfLogic(cur_square, current_p, true, 4); draw_square(sqbrush, current_p); } else { current_p.x = xy.x; current_p.y = xy.y; setSelfLogic(cur_square, current_p, true, 4); } } else { setSelfLogic(original, xy, false, 4); draw_square(new SolidBrush(this.BackColor), xy,original); setSelfLogic(cur_square, current_p, true, 4); draw_square(sqbrush, current_p); } } else { setSelfLogic(cur_square, current_p, true, 4); current_p.x = start_p.x; current_p.y = start_p.y; if (IsFail()) { MessageBox.Show("Fail!"); setTimer(false, false); return; } copyXY(a[outer][inner], ref cur_square); rotate_outer = outer; rotate_inner = inner; outer = rand(0, 6); inner = rand(0, 4); p.Invalidate(); Logic_Expunction(); Real_Expunction(); } move_flag = 'p'; cur_t.Enabled = true; } public void setTimer(bool slow, bool fast) { t_slow.Enabled = slow; t_fast.Enabled = fast; } public void draw(Panel p,bool bkColor) { Color color; if(bkColor) { color = p.BackColor; } else { color = sqbrush.Color; } for (int i = 0; i < 4; i++) { p.CreateGraphics().DrawRectangle(new Pen(Brushes.Chocolate, 1), (a[outer][inner][i].x - a[outer][inner][0].x + reference.x) * width, (a[outer][inner][i].y - a[outer][inner][0].y + reference.y) * height, width, height); } } #endregion #region 私有的方法 private bool Square_Move(char a, ref XY xy,ref XY []original) { switch (a) { case 'a': case 'A': if (CanLeft() && CanDown()) { xy.x = current_p.x; xy.y = current_p.y; current_p.x--; current_p.y++; } else if(CanDown()) { xy.x = current_p.x; xy.y = current_p.y; current_p.y++; } else return false; break; case 'd': case 'D': if (CanRight() && CanDown()) { xy.x = current_p.x; xy.y = current_p.y; current_p.x++; current_p.y++; } else if (CanDown()) { xy.x = current_p.x; xy.y = current_p.y; current_p.y++; } else return false; break; case 'w': case 'W': if(CanRotate()) { copyXY(cur_square, ref original); copyXY(afterChange_squar, ref cur_square); xy.x = current_p.x; xy.y = current_p.y; //current_p.y++; } break; default: if (CanDown()) { xy.x = current_p.x; xy.y = current_p.y; current_p.y++; } else return false; break; } return true; } private int rand(int least,int largest) { return ra.Next(least, largest); } private void copyXY(XY[] s, ref XY[] t) { for (int i = 0; i < 4; i++) { t[i].x = s[i].x; t[i].y = s[i].y; } } private void draw_square(SolidBrush sb, XY reference) { for (int i = 0; i < 4; i++) { this.CreateGraphics().FillRectangle(sb, (cur_square[i].x - cur_square[0].x + reference.x) * width, (cur_square[i].y - cur_square[0].y + reference.y) * height, width, height); } } private void draw_square(SolidBrush sb, XY reference,XY []orientation) { for (int i = 0; i < 4; i++) { this.CreateGraphics().FillRectangle(sb, (orientation[i].x - orientation[0].x + reference.x) * width, (orientation[i].y - orientation[0].y + reference.y) * height, width, height); } } private void setA() { a[0][0][0].x = 1; a[0][0][0].y = 1; a[0][0][1].x = 0; a[0][0][1].y = 1; a[0][0][2].x = 0; a[0][0][2].y = 2; a[0][0][3].x = 1; a[0][0][3].y = 0; a[0][1][0].x = 1; a[0][1][0].y = 1; a[0][1][1].x = 0; a[0][1][1].y = 0; a[0][1][2].x = 1; a[0][1][2].y = 0; a[0][1][3].x = 2; a[0][1][3].y = 1; a[0][2][0].x = 1; a[0][2][0].y = 1; a[0][2][1].x = 0; a[0][2][1].y = 1; a[0][2][2].x = 0; a[0][2][2].y = 2; a[0][2][3].x = 1; a[0][2][3].y = 0; a[0][3][0].x = 1; a[0][3][0].y = 1; a[0][3][1].x = 0; a[0][3][1].y = 0; a[0][3][2].x = 1; a[0][3][2].y = 0; a[0][3][3].x = 2; a[0][3][3].y = 1; //end 0 a[1][0][0].x = 1; a[1][0][0].y = 1; a[1][0][1].x = 0; a[1][0][1].y = 0; a[1][0][2].x = 0; a[1][0][2].y = 1; a[1][0][3].x = 1; a[1][0][3].y = 2; a[1][1][0].x = 1; a[1][1][0].y = 1; a[1][1][1].x = 0; a[1][1][1].y = 1; a[1][1][2].x = 1; a[1][1][2].y = 0; a[1][1][3].x = 2; a[1][1][3].y = 0; a[1][2][0].x = 1; a[1][2][0].y = 1; a[1][2][1].x = 0; a[1][2][1].y = 0; a[1][2][2].x = 0; a[1][2][2].y = 1; a[1][2][3].x = 1; a[1][2][3].y = 2; a[1][3][0].x = 1; a[1][3][0].y = 1; a[1][3][1].x = 0; a[1][3][1].y = 1; a[1][3][2].x = 1; a[1][3][2].y = 0; a[1][3][3].x = 2; a[1][3][3].y = 0; //end 1 a[2][0][0].x = 1; a[2][0][0].y = 1; a[2][0][1].x = 0; a[2][0][1].y = 0; a[2][0][2].x = 1; a[2][0][2].y = 0; a[2][0][3].x = 0; a[2][0][3].y = 1; a[2][1][0].x = 1; a[2][1][0].y = 1; a[2][1][1].x = 0; a[2][1][1].y = 0; a[2][1][2].x = 1; a[2][1][2].y = 0; a[2][1][3].x = 0; a[2][1][3].y = 1; a[2][2][0].x = 1; a[2][2][0].y = 1; a[2][2][1].x = 0; a[2][2][1].y = 0; a[2][2][2].x = 1; a[2][2][2].y = 0; a[2][2][3].x = 0; a[2][2][3].y = 1; a[2][3][0].x = 1; a[2][3][0].y = 1; a[2][3][1].x = 0; a[2][3][1].y = 0; a[2][3][2].x = 1; a[2][3][2].y = 0; a[2][3][3].x = 0; a[2][3][3].y = 1; //end 2 a[3][0][0].x = 1; a[3][0][0].y = 1; a[3][0][1].x = 0; a[3][0][1].y = 0; a[3][0][2].x = 1; a[3][0][2].y = 0; a[3][0][3].x = 1; a[3][0][3].y = 2; a[3][1][0].x = 2; a[3][1][0].y = 1; a[3][1][1].x = 2; a[3][1][1].y = 0; a[3][1][2].x = 1; a[3][1][2].y = 1; a[3][1][3].x = 0; a[3][1][3].y = 1; a[3][2][0].x = 1; a[3][2][0].y = 2; a[3][2][1].x = 0; a[3][2][1].y = 0; a[3][2][2].x = 0; a[3][2][2].y = 1; a[3][2][3].x = 0; a[3][2][3].y = 2; a[3][3][0].x = 1; a[3][3][0].y = 0; a[3][3][1].x = 2; a[3][3][1].y = 0; a[3][3][2].x = 0; a[3][3][2].y = 0; a[3][3][3].x = 0; a[3][3][3].y = 1; //end 3 a[4][0][0].x = 0; a[4][0][0].y = 1; a[4][0][1].x = 0; a[4][0][1].y = 0; a[4][0][2].x = 0; a[4][0][2].y = 2; a[4][0][3].x = 1; a[4][0][3].y = 0; a[4][1][0].x = 2; a[4][1][0].y = 1; a[4][1][1].x = 0; a[4][1][1].y = 0; a[4][1][2].x = 1; a[4][1][2].y = 0; a[4][1][3].x = 2; a[4][1][3].y = 0; a[4][2][0].x = 1; a[4][2][0].y = 2; a[4][2][1].x = 0; a[4][2][1].y = 2; a[4][2][2].x = 1; a[4][2][2].y = 0; a[4][2][3].x = 1; a[4][2][3].y = 1; a[4][3][0].x = 1; a[4][3][0].y = 1; a[4][3][1].x = 0; a[4][3][1].y = 0; a[4][3][2].x = 0; a[4][3][2].y = 1; a[4][3][3].x = 2; a[4][3][3].y = 1; //end 4 a[5][0][0].x = 1; a[5][0][0].y = 0; a[5][0][1].x = 0; a[5][0][1].y = 0; a[5][0][2].x = 2; a[5][0][2].y = 0; a[5][0][3].x = 3; a[5][0][3].y = 0; a[5][1][0].x = 0; a[5][1][0].y = 1; a[5][1][1].x = 0; a[5][1][1].y = 2; a[5][1][2].x = 0; a[5][1][2].y = 3; a[5][1][3].x = 0; a[5][1][3].y = 0; a[5][2][0].x = 1; a[5][2][0].y = 0; a[5][2][1].x = 0; a[5][2][1].y = 0; a[5][2][2].x = 2; a[5][2][2].y = 0; a[5][2][3].x = 3; a[5][2][3].y = 0; a[5][3][0].x = 0; a[5][3][0].y = 1; a[5][3][1].x = 0; a[5][3][1].y = 2; a[5][3][2].x = 0; a[5][3][2].y = 3; a[5][3][3].x = 0; a[5][3][3].y = 0; } private bool IsFail() { for (int i = 0; i < 4; i++) if (ha[cur_square[i].y - cur_square[0].y + current_p.y + 1][cur_square[i].x - cur_square[0].x + current_p.x]) { setSelfLogic(cur_square, current_p, true, 4); return true; } return false; } private void setSelfLogic(XY[] xy, XY reference,bool logic,int m) { for(int i=0;i<m;i++) { ha[xy[i].y - xy[0].y + reference.y][xy[i].x - xy[0].x + reference.x] = logic; } } private bool CanLeft() { for (int i = 0; i < 4; i++) { if (cur_square[i].x - cur_square[0].x + current_p.x - 1 < 0) return false; } setSelfLogic(cur_square, current_p, false, 4); for (int i = 0; i < 4; i++) if (ha[cur_square[i].y - cur_square[0].y + current_p.y][cur_square[i].x - cur_square[0].x + current_p.x - 1]) { setSelfLogic(cur_square, current_p, true, 4); return false; } setSelfLogic(cur_square, current_p, true, 4); return true; } private bool CanRight() { for (int i = 0; i < 4; i++) { if (cur_square[i].x - cur_square[0].x + current_p.x + 1 >= n) return false; } setSelfLogic(cur_square, current_p, false, 4); for (int i = 0; i < 4; i++) if (ha[cur_square[i].y - cur_square[0].y + current_p.y][cur_square[i].x - cur_square[0].x + current_p.x+1]) { setSelfLogic(cur_square, current_p, true, 4); return false; } setSelfLogic(cur_square, current_p, true, 4); return true; } private bool CanRotate() { XY topleft, buttomright; topleft = new XY(); buttomright = new XY(); topleft.x = cur_square[0].x; topleft.y = cur_square[0].y; buttomright.x = cur_square[0].x; buttomright.y = cur_square[0].y; for (int i = 1; i < 4; i++) { buttomright.x = buttomright.x > cur_square[i].x ? buttomright.x : cur_square[i].x; buttomright.y = buttomright.y > cur_square[i].y ? buttomright.y : cur_square[i].y; topleft.x = topleft.x < cur_square[i].x ? topleft.x : cur_square[i].x; topleft.y = topleft.y < cur_square[i].y ? topleft.y : cur_square[i].y; } for (int y = topleft.y; y <= buttomright.y; y++) for (int x = topleft.x; x <= buttomright.x; x++) if (ha[y - cur_square[0].y + current_p.y][x - cur_square[0].x + current_p.x] && Isnotinself(new XY(x - cur_square[0].x + current_p.x, y - cur_square[0].y + current_p.y), cur_square, current_p, 4)) return false; Rotate(a[rotate_outer], ref afterChange_squar, 4); int temp_x; topleft.x = afterChange_squar[0].x; topleft.y = afterChange_squar[0].y; buttomright.x = afterChange_squar[0].x; buttomright.y = afterChange_squar[0].y; temp_x = afterChange_squar[0].x; for (int i = 1; i < 4; i++) { buttomright.x = buttomright.x > afterChange_squar[i].x ? buttomright.x : afterChange_squar[i].x; buttomright.y = buttomright.y > afterChange_squar[i].y ? buttomright.y : afterChange_squar[i].y; topleft.x = topleft.x < afterChange_squar[i].x ? topleft.x : afterChange_squar[i].x; topleft.y = topleft.y < afterChange_squar[i].y ? topleft.y : afterChange_squar[i].y; } for (int i = 0; i < 4; i++) { if (afterChange_squar[i].y - afterChange_squar[0].y + current_p.y >= m - 1 || afterChange_squar[i].x - afterChange_squar[0].x + current_p.x > n - 1 || afterChange_squar[i].x - afterChange_squar[0].x + current_p.x < 0) return false; } for (int y = topleft.y; y <= buttomright.y; y++) for (int x = topleft.x; x <= buttomright.x; x++) if ((ha[y - afterChange_squar[0].y + current_p.y][x - afterChange_squar[0].x + current_p.x] && Isnotinself(new XY(x - afterChange_squar[0].x + current_p.x, y - afterChange_squar[0].y + current_p.y), cur_square, current_p, 4))) return false; return true; } private bool CanDown() { for (int i = 0; i < 4; i++) { if (cur_square[i].y - cur_square[0].y + current_p.y + 1 > m-1) return false; } setSelfLogic(cur_square, current_p, false, 4); for (int i = 0; i < 4; i++) if (ha[cur_square[i].y - cur_square[0].y + current_p.y + 1][cur_square[i].x - cur_square[0].x +current_p.x]) { setSelfLogic(cur_square, current_p, true, 4); return false; } setSelfLogic(cur_square, current_p, true, 4); return true; } private void Rotate(XY[][] source, ref XY[] retur,int m) { retur[0].x = source[rotate_inner][0].x; retur[0].y = source[rotate_inner][0].y; rotate_inner++; rotate_inner = rotate_inner%4; for(int i=0;i<4;i++) { retur[i].x = source[rotate_inner][i].x; retur[i].y = source[rotate_inner][i].y; } } private bool Isnotinself(XY xy,XY []self,XY reference,int m) { for(int i=0;i<m;i++) { if ((self[i].x - self[0].x + reference.x) == xy.x && (self[i].y - self[0].y + reference.y) == xy.y) return false ; } return true; } private void Logic_Expunction() { for (int i = m - 1; i >= 0; i--) { int j; for (j = 0; j < n; j++) if (ha[i][j] == false) break; if (j == n) { for (int k = i; k >= 1; k--) { for (int e = 0; e < n; e++) ha[k][e] = ha[k - 1][e]; } for (int e = 0; e < n; e++) ha[0][e] = false; mark += 10; markl.Text = mark.ToString(); i++; } } } private void Real_Expunction() { for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) if (ha[i][j]) this.CreateGraphics().FillRectangle(sqbrush, j * width, i * height, width, height); else this.CreateGraphics().FillRectangle(new SolidBrush(this.BackColor), j * width, i * height, width, height); } private void panel_Paint(object sender, PaintEventArgs e) { Logic_Expunction(); Real_Expunction(); } #endregion } }

    4
    72
    242KB
    2009-05-18
    0
  • c#做的俄罗斯方块完整工程

    提供了一个核心的类,功能全面,您可基于此类做扩展开发,包括界面的扩展,方块定义的扩展,方块颜色的扩展等,总之此类的开发充分考虑了以后可能的扩展。另外,因为做了很好的封装,自成体系,所以您大可不为会有繁琐的API调用而担心,此类的外部接口调用简单,提供的API仅几个,但并不意味着其功能不够强大,恰恰相反,这一点您在做扩展开发时相信您会有深切的体会,时已深夜,恕不多言,如有什么问题,可以联系我,我会尽快为您解答。下面是通信方式: Email:5zhou1zhou8@sina.com Phone: 15805198612 QQ: 978702289

    0
    82
    12.09MB
    2009-05-15
    9
  • 扫雷游戏之C#实现(仅一个核心类,一个公有接口)

    完整的扫雷游戏C#工程,另附核心实现类(针对初学者),核心类公有接口仅一个,方便您在此基础上的外围开发。(支持原创!)

    0
    65
    62KB
    2009-04-25
    0
  • vc做的锁屏幕程序,附源码

    解锁在桌面鼠标左右键按如下序列单击: l:左键 r:右键 序列:lrrlrl 点入上述序列后任意左右键单击 如果你是懂vc,可以修改源码,定义自己的序列,很简单!

    2
    71
    26KB
    2009-04-10
    10
关注 私信
上传资源赚积分or赚钱