自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(21)
  • 收藏
  • 关注

原创 实验8,编写一个模板函数求数组中的最大值和最小值

#include using namespace std;template //模板声明,T1为类型参数T1 max(T1 *p1,T1 n) //定义模板函数max,求最大值{ int j=0; for(int i=1;i<n;i++) if(p1[i]>p1[j]) j=i; retu

2015-06-02 21:34:58 12513

原创 8.18在类模板外定义成员函数,实现3个数求和

#includeusing namespace std;template //模板声明,其中T为类型参数class sum{ //类模板名为sum private: T

2015-06-02 21:06:34 2604

原创 8.17建立一个类模板实现求3个数之和

#includeusing namespace std;templateclass sum{ private: T x,y,z; public: sum(T a,T b,T c) { x=a; y=b; z=c; } T add() { return x+y+z; } void print() { cout<<x<<" "

2015-06-02 20:41:16 2638

原创 8.15编写一个模板函数,求数组中最大元素

#includeusing namespace std;template //模板声明,其中T1为类型参数T1 max(T1* set,T1 n) //定义有一个类型参数的函数模板{ int j=0; for(int i=1;i<n;i++) { if(set[i]>set[j])

2015-06-02 20:22:32 9966

原创 8.16编写一个函数模板,使用冒泡法将数组内容从小排列到大

#includeusing namespace std;template void sort(T1 *set,T2 n) //用冒泡法从小到大排序{ T2 temp; for(int i=1;i<n;i++) { for(int j=n-1;j>=i;j--) if(set[j-1]>set[j]) {

2015-06-02 20:08:56 9439

原创 编写一个程序,实行两个复数相加

#includeusing namespace std;class complex{ double real; double imag;public: complex(double r=0.0,double i=0.0); //定义带参数的构造函数 friend complex operator +(complex&,complex &);

2015-05-26 23:12:07 2764

原创 编写一个程序,实行两个时间相加

#include#includeusing namespace std;class Time{public: Time(int h=0,int m=0,int s=0); //定义构造函数 Time operator +(Time&); //运算符“+”重载为友元函数 void disptime(s

2015-05-26 23:10:46 1605

原创 5.18设计一个基类,再派生出两个子类

#include#includeusing namespace std;class person{protected: int num; string name;public: person(int num1,string name1) { num=num1;name=name1; }void print() { cout<<"编号为:"<<num<<en

2015-05-21 08:50:14 856

原创 5.19 设计一个虚基类

#include #include using namespace std;class base{private: string name; int old;public: base(string name1,int old1) { name=name1; old=old1; } void print() { cout<<"姓名为:"<<name<<endl;

2015-05-20 23:50:52 452

原创 4.22

#include #includeusing namespace std;class point{ double x,y;public: point(double x1,double y1); friend void showpoint(point &a,point &b); double get_x(); double get_y();};point::point(do

2015-04-24 21:34:12 346 1

原创 4.21

#include #include using namespace std;class student{private: float num; string name; float score; static int count; static float sum; float ave;public: student(float num1,string name1,flo

2015-04-24 17:45:17 435 1

原创 定义一个学生类

#include #includeusing namespace std;class student;class teacher{ float num; string name;public: teacher(float num1,string name1); void set(student &s); void show();};class student{ flo

2015-04-23 20:27:37 2505 1

原创 4.20

#include using namespace std;class book{ float qu; float price;public: book(float qu1,float price2); void show();};book::book(float qu1,float price1){ qu=qu1; price=price1;}void book::sh

2015-04-17 23:36:53 390 1

原创 4.19

#include using namespace std;class book{ float qu; float price;public: book(float qu1,float price2); void show();};book::book(float qu1,float price1){ qu=qu1; price=price1;}void book::sh

2015-04-17 23:31:23 393 1

原创 4.17

#include using namespace std;class student{ float num; float score;public: student(float num1,float score1); void show();};student::student(float num1,float score1){ num=num1;score=score1;

2015-04-17 23:11:51 396 1

原创 3.24

#include using namespace std;class Date{ private : int year; int month; int day; public : void getyear(); void getmonth(); void getday(); void setdate(); void printDate();

2015-04-02 22:51:51 392 1

原创 3.23

#include using namespace std;class cylinder{ private: double radius; double hight; double v; public: cylinder(double r,double h); void vol();};cylinder::cylinder(double r,double h)

2015-04-02 22:44:54 319 1

原创 3.22

#includeusing namespace std;class Circle{ private: double radius; double cs; public: void area() { cs=3.14*radius*radius; cout<<"圆的面积为:"<<cs<<endl; } void radius_

2015-04-01 23:17:21 384 1

原创 2.30

#include #includeusing namespace std;int sroot(int x){ int c=sqrt(x); return c;}long int sroot(long int y){ return sqrt(y);}double sroot(double z){ return sqrt(z);}int main(){ int a=

2015-04-01 17:27:12 365 1

原创 2.29

#include using namespace std;int main(){ int i; int *p; p=new int[20]; p[0]=1; p[1]=1; for(i=2;i<20;i++) p[i]=p[i-1]+p[i-2]; for(i=0;i<20;i++) cout<<p[i]<<" "; cout<<endl; d

2015-04-01 17:22:39 400 3

原创 2.28

#include#includeusing namespace std;int main(){ int x,y,c; cout<<"请输入两个数:"<<endl; cin>>x>>y; c=pow( x, y); cout<<"x^y="<<c<<endl; return 0;}

2015-04-01 17:16:28 387 1

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除