开源一个sheet表格类

可以建立表格,输入内容,居中显示
复制代码
#include <iostream>
#include <conio.h>
#include < string>
#include <graphics.h>
using  namespace std;
class sheet{
public:
    sheet( int l= 5, int c= 5, int width= 80, int highth= 40, int posx= 0, int posy= 0);
     // 行数,列数,行宽,列宽,起始位置x,y
     void put_txt( int x, int y, char *s);
private:
     int col,lin,col_high,lin_width,pos_x,pos_y;
};
sheet::sheet( int l, int c, int width, int highth, int posx, int posy)
{
    col=c;
    lin=l;
    lin_width=width;
    col_high=highth;
    pos_x=posx;
    pos_y=posy;
     int grax,gray;
    grax=col*lin_width;
    gray=lin*col_high;
     int i,j;
     for(i= 0;i<=grax;i+=lin_width)
        line(i+pos_x, 0+pos_y,i+pos_x,gray+pos_y);
     for(j= 0;j<=gray;j+=col_high)
        line( 0+pos_x,j+pos_y,grax+pos_x,j+pos_y);
}
void sheet::put_txt( int x, int y, char *s)
{
    outtextxy((x- 1)*lin_width+ 20+pos_x,(y- 1)*col_high+ 8+pos_y,s);
}

int main()
{
    initgraph( 800, 600);
//   sheet a(15,6,100,30,20,20);
    sheet a;
     string s= " 张三 ";
    a.put_txt( 2, 2,s);
    getch();
}
复制代码

博主ma6174对本博客文章(除转载的)享有版权,未经许可不得用于商业用途。转载请注明出处http://www.cnblogs.com/ma6174/

对文章有啥看法或建议,可以评论或发电子邮件到ma6174@163.com


本文转自ma6174博客园博客,原文链接:http://www.cnblogs.com/ma6174/archive/2012/01/01/2309495.html ,如需转载请自行联系原作者
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值