#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();
}
#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();
}