2012年12月7日

摘要: #include#include#include#includeusing namespace std;ifstream infile1;ifstream infile2;ifstream infile3;class qclx{string checi; string start,end;string type;string distance;string statime,endtime;double price;int zws;public:void input();void output();friend void change1();};void qclx::input(){infile 阅读全文
posted @ 2012-12-07 23:39 木本 阅读(326) 评论(0) 推荐(0) 编辑
摘要: 实验要求:自定义如下形式的一个称为point的类,其对象表示平面上的一个点(x,y),并通过类成员方式对该类重载二目运算符“+”和“^”,用来求出两个对象的和以及两个对象(平面点)的距离。各运算符的使用含义(运算结果)如下所示:(1.2,-3.5)+(-1.5,6)=(-0.3,2.5);(1.2,-3.5)^(-1.5,6)=9.87623。编写主函数,说明类对象,而后通过类对象实现所定义的相关运算(以验证其正确性)。classpoint{doublex,y;public:point(doublex0=0,doubley0=0){x=x0;y=y0;}pointoperator+(point 阅读全文
posted @ 2012-12-07 23:38 木本 阅读(512) 评论(0) 推荐(0) 编辑
摘要: #include#includeusingnamespacestd;classStudent{public:Student();voidoutput();voidchange();voidsort1();voidsort0();voidSum();private:stringname;stringsex;doublescore[5];doubleold;stringclass_1;stringstr[5];};Student::Student(){name="梁燕婷";sex="女";old=19;class_1="软件114班";s 阅读全文
posted @ 2012-12-07 23:35 木本 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 假设某商店有如下几种货品:衬衣、帽子、立柜。每一种货物都有与其关联的说明信息。衬衣:单价、产地、布料;帽子:单价、产地、布料、样式(平顶或尖顶);立柜:单价、产地、木料、颜色。对这些商品的操作有:商品的进库(增加某类商品及其库存量),商品的出库(减少某类商品及其库存量),某类货品总价格的计算。要求自行设计数据结构,用类的继承与派生关系将上述的各种货品表示出来,并使用类的构造函数来初始化每一类对象的初始数据。而后将上述的商品管理计算机化,完成操作要求的功能。二、实验过程(实验步骤、记录、数据、)#include#includeusingnamespacestd;classShirt{public 阅读全文
posted @ 2012-12-07 23:28 木本 阅读(509) 评论(0) 推荐(0) 编辑
摘要: 了解多态性的概念,了解虚函数的作用及使用方法,了解静态关联和动态关联的概念和用法,了解纯虚函数和抽象类的概念和用法。实验要求:声明抽象基类Shape,由它派生出3个派生类:Circle(圆形)、Rectangle(矩形)、Triangle(三角形),用一个函数printArea分别输出以上三者的面积,3个图形的数据在定义对象时给定。二、实验过程(实验步骤、记录、数据、)#includeconstdoublePI=3.1415925;classShape{public:virtualdoublearea()const{return0;}virtualvoidshapeName()const=0; 阅读全文
posted @ 2012-12-07 23:26 木本 阅读(253) 评论(0) 推荐(0) 编辑
摘要: 自定义三个text型磁盘文件f1.txt、f2.txt和f3.txt,并对它们进行指定的读写操作:先往f1.txt以及f2.txt中写出数据,之后再将它们读入而形成f3.txt文件。实验要求:通过使用运算符“>>”和“<<”,对自定义的text型磁盘文件进行如下的指定操作。(1)对i=1,2,3,...,15,计算d=i*i+0.5,并将15个结果写出到自定义的text型磁盘文件f1.txt中(注意,f1文件中的数据从小到大有序);(2)对i=1,2,3,...,10,计算d=10*i+0.5,并将10个结果写出到自定义的text型磁盘文件f2.txt中,而后再写出第1 阅读全文
posted @ 2012-12-07 23:25 木本 阅读(322) 评论(0) 推荐(0) 编辑
摘要: 1.设计并编制自定义函数chgStr,完成指定功能;而后在main中调用chgStr验证其正确性。2.通过指针参数的使用实现“双向传值”:函数参数为字符指针;调用该函数时,对应实参为一维字符数组名;通过指针参数op将结果带回到调用函数中去。实验要求:编制具有如下原型的函数:voidchgStr(char*ip,char*op);负责将ip所指输入串中的各字符按照指定规则进行变换后,存放到由op指向的输出串中。即要从头到尾逐字符地对ip所指向的字符串进行如下处理:(1)若ip所指当前字符为字母,则将其改变大小写后存放到结果串op中。(2)若ip所指当前字符是一个数字字符,则将其变换为另一个数字字 阅读全文
posted @ 2012-12-07 23:19 木本 阅读(244) 评论(0) 推荐(0) 编辑
摘要: #includeusingnamespacestd;classComplex{public:Complex(doubler=0,doublei=0):real(r),imag(i){}voidinput(){cin>>real>>imag;}voiddisplay(){cout<<"("<<real<<","<<imag<<"i)"<<endl;}doublereal;doubleimag;};intmain(){Complexoperat 阅读全文
posted @ 2012-12-07 23:12 木本 阅读(224) 评论(0) 推荐(0) 编辑
摘要: #includeusingnamespacestd;classComplex{public:Complex(doubler=0,doublei=0):real(r),imag(i){}Complexoperator+(Complex&c1);Complexoperator-(Complex&c1);Complexoperator*(Complex&c1);Complexoperator/(Complex&c1);voidinput(){cin>>real>>imag;}voiddisplay(){cout<<"(&q 阅读全文
posted @ 2012-12-07 23:11 木本 阅读(308) 评论(0) 推荐(0) 编辑
摘要: #include#includeusing namespace std;struct student{int num;char name[20];student *next;};void print(student *p1);student *creat(student *stu);student *del(student *head);student *insert(student *head,student *q);int main(){student *p1,*stu,*q;q=new student;cout<<"输入一个要插入的num和name"< 阅读全文
posted @ 2012-12-07 23:09 木本 阅读(117) 评论(0) 推荐(0) 编辑

导航