`
- 浏览:
1004560 次
- 性别:
- 来自:
北京
-
-
-
-
#ifndef_FRAME_PIC_H
-
#define_FRAME_PIC_H
-
#include<iostream>
-
#include"Picture.h"
-
usingnamespacestd;
-
namespacelwj
- {
-
classFrame_Pic:publicP_Node
- {
-
friendclassPicture;
-
friendPictureframe(constPicture&);
-
friendPicturereframe(constPicture&,char,char,char);
-
Frame_Pic(constPicture&,char='+',char='|',char='-');
-
intheight()const
- {
-
returnp.height()+2;
- }
-
intwidth()const
- {
-
returnp.width()+2;
- }
-
voiddisplay(ostream&,int,int)const;
-
Picturedoreframe(char,char,char);
- Picturep;
-
charcorner;
-
charsideborder;
-
chartopborder;
- };
- Frame_Pic::
-
Frame_Pic(constPicture&pic,charc,chars,chart):
- p(pic),corner(c),sideborder(s),topborder(t)
- {}
-
voidFrame_Pic::
-
display(ostream&os,introw,intwd)const
- {
-
if(row<0||row>=height())
- pad(os,0,wd);
-
else
- {
-
if(row==0||row==height()-1)
- {
- os<<corner;
-
inti=p.width();
-
while(--i>=0)os<<topborder;
- os<<corner;
-
}else
- {
- os<<sideborder;
- p.display(os,row-1,p.width());
- os<<sideborder;
- }
- pad(os,width(),wd);
- }
- }
- PictureFrame_Pic::
-
doreframe(charc,chars,chart)
- {
-
returnnewFrame_Pic(reframe(this->p,c,s,t),c,s,t);
- }
-
Pictureframe(constPicture&pic)
- {
-
returnnewFrame_Pic(pic);
- }
- }
-
#endif
-
-
-
-
#ifndefHCAT_PIC_H
-
#defineHCAT_PIC_H
-
#include"Picture.h"
-
namespacelwj
- {
-
classHCat_Pic:publicP_Node
- {
-
friendPictureoperator|(constPicture&,constPicture&);
-
friendPicturereframe(constPicture&,char,char,char);
-
HCat_Pic(constPicture&,constPicture&);
-
intheight()const
- {
-
returnmax(left.height(),right.height());
- }
-
intwidth()const
- {
-
returnleft.width()+right.width();
- }
-
voiddisplay(ostream&,int,int)const;
-
Picturedoreframe(charc,chars,chart)
- {
-
returnnewHCat_Pic(reframe(left,c,s,t),
- reframe(right,c,s,t));
- }
-
private:
- Pictureleft,right;
- };
- HCat_Pic::
-
HCat_Pic(constPicture&l,constPicture&r):
- left(l),right(r)
- {
- }
-
voidHCat_Pic::
-
display(ostream&os,introw,intwd)const
- {
- left.display(os,row,left.width());
- right.display(os,row,right.width());
- pad(os,width(),wd);
- }
- }
-
#endif
-
-
-
-
#include<iostream>
-
#include<string>
-
#include"Picture.h"
-
usingnamespacestd;
-
usingnamespacelwj;
-
intmain()
- {
-
constchar*cs[]={"hello","world"};
- Picturep(cs,2);
- Pictureq=frame(p);
- cout<<frame(p|(q&p))<<endl;
- cout<<endl<<endl;
-
cout<<reframe(frame(p|(q&p)),'^','~','*')<<endl;
- }
-
-
-
#include"Picture.h"
-
#include"String_Pic.h"
-
#include"Frame_Pic.h"
-
#include"HCat_Pic.h"
-
#include"VCat_Pic.h"
-
namespacelwj
- {
- Picture::
-
Picture(constchar*const*str,intn):
-
p(newString_Pic(str,n))
- {}
- Picture::
- Picture(P_Node*p_node):p(p_node)
- {}
- Picture::
-
Picture(constPicture&orig):p(orig.p)
- {
- orig.p->use++;
- }
- Picture::
- ~Picture()
- {
-
if(--p->use==0)
-
deletep;
- }
- Picture&Picture::
-
operator=(constPicture&orig)
- {
- orig.p->use++;
-
if(--p->use==0)
-
deletep;
- p=orig.p;
-
return*this;
- }
-
intPicture::
-
height()const
- {
-
returnp->height();
- }
-
intPicture::
-
width()const
- {
-
returnp->width();
- }
-
voidPicture::
-
display(ostream&o,intx,inty)const
- {
- p->display(o,x,y);
- }
-
ostream&operator<<(ostream&os,constPicture&picture)
- {
-
intht=picture.height();
-
for(inti=0;i<ht;i++)
- {
- picture.display(os,i,picture.width());
- os<<endl;
- }
-
returnos;
- }
-
Picturereframe(constPicture&pic,charc,chars,chart)
- {
-
returnpic.p->doreframe(c,s,t);
- }
-
Pictureoperator|(constPicture&l,constPicture&r)
- {
-
returnnewHCat_Pic(l,r);
- }
-
Pictureoperator&(constPicture&t,constPicture&b)
- {
-
returnnewVCat_Pic(t,b);
- }
- }
-
-
-
-
#ifndef_PICTURE_H
-
#define_PICTURE_H
-
#include<iostream>
-
usingnamespacestd;
-
namespacelwj
- {
-
classP_Node;
-
classPicture
- {
-
friendostream&operator<<(ostream&,constPicture&);
-
friendPictureframe(constPicture&);
-
friendPictureoperator&(constPicture&,constPicture&);
-
friendPictureoperator|(constPicture&,constPicture&);
-
friendPicturereframe(constPicture&,char,char,char);
-
friendclassString_Pic;
-
friendclassFrame_Pic;
-
friendclassHCat_Pic;
-
friendclassVCat_Pic;
-
public:
- Picture();
-
Picture(constchar*const*,int);
-
Picture(constPicture&);
- ~Picture();
-
Picture&operator=(constPicture&);
-
private:
- Picture(P_Node*);
-
intheight()const;
-
intwidth()const;
-
voiddisplay(ostream&o,intx,inty)const;
- P_Node*p;
- };
-
classP_Node
- {
-
friendclassPicture;
-
friendPicturereframe(constPicture&,char,char,char);
-
protected:
- P_Node():use(1){}
-
virtual~P_Node(){}
-
virtualintheight()const=0;
-
virtualintwidth()const=0;
-
virtualvoiddisplay(ostream&,int,int)const=0;
-
virtualPicturedoreframe(char,char,char)=0;
-
intmax(intx,inty)const
- {
-
returnx>y?x:y;
- }
-
intuse;
- };
-
staticvoidpad(ostream&os,intx,inty)
- {
-
for(inti=x;i<y;i++)
-
os<<"";
- }
- }
-
#endif
-
-
-
-
#ifndef_STRING_PIC_H
-
#define_STRING_PIC_H
-
#include"Picture.h"
-
namespacelwj
- {
-
classString_Pic:publicP_Node
- {
-
friendclassPicture;
-
String_Pic(constchar*const*,int);
- ~String_Pic(){}
-
intheight()const
- {
-
returnsize;
- }
-
intwidth()const
- {
-
intn=0;
-
for(inti=0;i<size;i++)
- n=P_Node::max(n,strlen(data[i]));
-
returnn;
- }
-
voiddisplay(ostream&,int,int)const;
-
Picturedoreframe(char,char,char)
- {
- use++;
-
returnthis;
- }
-
char**data;
-
intsize;
- };
- String_Pic::
-
String_Pic(constchar*const*p,intn):
-
data(newchar*[n]),size(n)
- {
-
for(inti=0;i<n;i++)
- {
-
data[i]=newchar[strlen(p[i])+1];
- strcpy(data[i],p[i]);
- }
- }
-
voidString_Pic::
-
display(ostream&os,introw,intwidth)const
- {
-
intstart=0;
-
if(row>=0&&row<height())
- {
- os<<data[row];
- start=strlen(data[row]);
- }
- pad(os,start,width);
- }
- }
-
#endif
-
-
-
-
#ifndef_VCAT_PIC_H
-
#define_VCAT_PIC_H
-
#include"Picture.h"
-
namespacelwj
- {
-
classVCat_Pic:publicP_Node
- {
-
friendPictureoperator&(constPicture&,constPicture&);
-
friendPicturereframe(constPicture&,char,char,char);
-
friendclassPicture;
-
VCat_Pic(constPicture&,constPicture&);
-
intheight()const
- {
-
returntop.height()+bottom.height();
- }
-
intwidth()const
- {
-
returnmax(top.width(),bottom.width());
- }
-
voiddisplay(ostream&,int,int)const;
-
Picturedoreframe(charc,chars,chart)
- {
-
returnnewVCat_Pic(reframe(top,c,s,t),
- reframe(bottom,c,s,t));
- }
- Picturetop,bottom;
- };
- VCat_Pic::
-
VCat_Pic(constPicture&t,constPicture&b):
- top(t),bottom(b)
- {}
-
voidVCat_Pic::
-
display(ostream&os,introw,intwd)const
- {
-
if(row>=0&&row<top.height())
- top.display(os,row,wd);
-
elseif(row<top.height()+bottom.height())
- bottom.display(os,row-top.height(),wd);
-
else
- pad(os,0,wd);
- }
- }
-
#endif
分享到:
Global site tag (gtag.js) - Google Analytics
相关推荐
SPOOLing算法模拟 C++实现 SPOOLing算法模拟 C++实现 SPOOLing算法模拟 C++实现 SPOOLing算法模拟 C++实现
智能优化算法————》模拟退火算法————》C++实现
模拟电子技术基础 康华光 模拟部分第十章
模拟CMD的小程序,用C++实现,用户只需加入自己的dll文件,dll中为用户所写的命令函数,以及加入到FunctionInfo.txt文件中,就可以加入自己定义的命令了。无需对整个程序重新编译。 提供全部源码,并已经加入30多个...
模拟电子技术基础课件:第十章直流稳压电源.ppt
基于C++的ATM机模拟程序系统源码。基于C++基于C++的ATM机模拟程序系统源码。基于C++的ATM机模拟程序系统源码。基于C++的ATM机模拟程序系统源码。基于C++的ATM机模拟程序系统源码。基于C++的ATM机模拟程序系统源码。...
模拟鼠标单击、双击 C++实现,欢迎大家下载!模拟鼠标单击、双击 C++实现,欢迎大家下载!模拟鼠标单击、双击 C++实现,欢迎大家下载!模拟鼠标单击、双击 C++实现,欢迎大家下载!模拟鼠标单击、双击 C++实现,欢迎...
模拟计算机 用c++实现
C++ 实现银行排队服务模拟
在linux下实现C++对文件系统的操作。可以显示文件信息,实现pwd功能操作所在位置,增加,删除文件。copy文件查找文件。
本资源用c++模拟操作系统的实现 主要内容:1.进程控制 2.分页式存储管理 3.设备管理4.文件管理 5.进程调度 有问题 联系 lx15636825085@163.com
计算机操作系统的实验课:磁盘调度算法的c++模拟实现。包含可直接执行的工程压缩包,有详尽的注释。
手机模拟通讯录-C++实现 功能描述: 建立模拟的手机通讯录,要求: 基本的增删改功能; 基本字段信息:姓名,手机号(11位),工作电话(8位),工作单位; 不允许两人或多人手机号相同,但是工作电话可以相同,...
这个是很辛苦做好的 里面的东西也比较的详细 导入到电脑上可以直接运行 模拟ATM的实现 是基于C++语言完成的
一个关于电梯调度算法的模拟程序,用c++实现,比较实用
C++ 模拟实现signal/slot
1、C++电梯模拟程序 2、关于电梯算法的C++实现
第十章+模拟卷.rar
c++编写的实现四元数操作的类。采用了函数重载来对各种运算符号重新定义,一边实现四元数可以直接按照常规的四则运算一样进行操作。