一般情况下,考研有择校应该注重所报考的院校的知名度,比如说是不是985,211等,但是并不是所有的学校 计算机专业都非常强,这时你可以考虑一下综合排名不是特别靠前,但是个别专业在业内很有知名度的专业性院校。比如说北邮,或者其他邮电类学校。具体选择需要结合自己的实力,和兴趣,个人观点,为了长远发展,建议还是报考综合性院校要好一点,
public class Rectangle{ private int width; private int height; public Rectangle(){ thiswidth = 10; thisheight = 10; } public Rectangle(int width, int height){ thiswidth = width; thisheight = height; } public int area(){ return width height; } //省略getter/setter }
太多了,不想写注释,看不懂联系我!
#include <iostream>
#include<cmath>
using namespace std;
//Shape可以设计为点类Point
class Point
{
public:
Point(double x = 0, double y = 0);
virtual void display() const;
double getX() const
{
return x;
}
double getY() const
{
return y;
}
void setPoint(double, double);
protected:
double x, y;
};
Point::Point(double a, double b)
{
x = a;
y = b;
}
void Point::display() const
{
cout << "x=" << x << " y=" << y << endl;;
}
void Point::setPoint(double a, double b)
{
x = a;
y = b;
}
class Circle: public Point
{
public:
Circle(double x = 0, double y = 0, double r = 0);
void display() const;
void setRadius(double);
double getRadius() const;
double area() const;
double perimeter() const;
private:
double radius;
};
Circle::Circle(double a, double b, double r):Point(a, b),radius(r){}
void Circle::display() const
{
Point::display();
cout << "r=" << radius << endl;
}
void Circle::setRadius(double r)
{
radius = r;
}
double Circle::getRadius() const
{
return radius;
}
double Circle::area() const
{
return 314159 radius radius;
}
double Circle::perimeter() const
{
return 2 314159 radius;
}
class Cylinder: public Circle
{
public:
Cylinder(double x, double y, double r, double h);
void display() const;
void setHeight(double);
double getHeight() const;
double area() const;
double volume() const;
protected:
double height;
};
Cylinder::Cylinder(double a, double b, double r, double h):Circle(a,b,r), height(h){}
void Cylinder::display() const
{
Circle::display();
cout << "height=" << height << endl;
}
void Cylinder::setHeight(double h)
{
height = h;
}
double Cylinder::getHeight() const
{
return height;
}
double Cylinder::area() const
{
return 2 Circle::area() + Circle::perimeter() height;
}
double Cylinder::volume() const
{
return Circle::area() height;
}
class InSquare:public Circle
{
public:
InSquare(double x, double y, double r);
double area() const;
double perimeter() const;
};
InSquare::InSquare(double a, double b, double r):Circle(a, b, r){}
double InSquare::area() const
{
return 2 Circle::getRadius() Circle::getRadius();
}
double InSquare::perimeter() const
{
return 4 sqrt(Circle::getRadius() Circle::getRadius() + Circle::getRadius() Circle::getRadius());
}
class OutSquare:public Circle
{
public:
OutSquare(double x, double y, double r);
double area() const;
double perimeter() const;
};
OutSquare::OutSquare(double a, double b, double r):Circle(a, b, r){}
double OutSquare::area() const
{
return 4 Circle::getRadius() Circle::getRadius();
}
double OutSquare::perimeter() const
{
return 4 2 Circle::getRadius();
}
class Rcetangle: public Point
{
public:
Rcetangle(double a=1, double b=1, double c=1);
void display() const;
private:
double a, b, c;
};
Rcetangle::Rcetangle(double aa, double bb, double cc)
{
a = aa;
b = bb;
c = cc;
}
void Rcetangle::display() const
{
cout << "a=" << a << " b=" << b << " c=" << c << endl;
}
int main()
{
Point p=NULL;
Point pp(1, 2);
Circle c(3, 4, 23);
Cylinder cy(5, 6, 34, 53);
InSquare is(2, 5, 55);
OutSquare os(4, 1, 48);
Rcetangle r(12, 34, 56);
p = &pp;
cout << "点: " << endl;
p->display();
p = &c;
cout << endl << "圆:" << endl;
p->display();
cout << "area=" << carea() << endl;
cout << "perimeter=" << cperimeter() << endl;
p = &cy;
cout << endl << "圆柱: " << endl;
p->display();
cout << "area=" << cyarea() << endl;
cout << "volume=" << cyvolume() << endl;
cout << endl << "内接正方形: " << endl;
cout << "area=" << isarea() << endl;
cout << "perimeter=" << isperimeter() << endl;
cout << endl << "外切正方形: " << endl;
cout << "area=" << osarea() << endl;
cout << "perimeter=" << osperimeter() << endl;
p = &r;
cout << endl << "三角形: " << endl;
p->display();
return 0;
}
,但是毕竟很相似了,因为解决问题的方法是一致的
你自己修改一下,如果还有任何问题,m我
#include<iostream>
#include<string> //控制字符串的头文件
using namespace std;
class tong //建立同学录的一个类
{
public:
tong(); //构造函数
tong(char n[20],char se,int ag,int te,int qq);
~tong();
void Set();//添加
void Delete();//删除
void Alter();//修改
void List();//显示
void RearchN();
void RearchT();
void RearchQ();
private:
char name[20];
int age,telphone,QQ;
char sex;
};
tong::tong()//构造函数
{
strcpy(name, "");
sex='M';
age=0;
telphone=0;
QQ=0;
}
tong::tong(char n[20],char se,int ag,int te,int qq)
{
strcpy(name, n);
sex=se;
age=ag;
telphone=te;
QQ=qq;
}
tong::~tong(){}
tongs[50];int i=0;int j=0;
char name[20];int age,telphone,QQ;char sex;
void tong::Set()
{
cout<<"请输入姓名:"<<endl;
cin>>name;
cout<<"请输入性别:"<<endl;
cin>>sex;
cout<<"请输入年龄:"<<endl;
cin>>age;
cout<<"电话号码:"<<endl;
cin>>telphone;
cout<<"QQ号码:"<<endl;
cin>>QQ;
j++;
s[i]=new tong(name,sex,age,telphone,QQ);
i++;
}
void tong:: Delete() //(2)删除人员(Delete)
{
cin>>name;
for(int h=0;h<i;h++)
{
if(strcmp(name,s[h]->name)==0)
{
i--;
s[h]=s[h+1];
h++;
}
else cout<<"您要求删除的对象本来就不存在!请检查输入的正确性!";
}
}
void tong::Alter() //(3)修改数据(Alter)
{
cout<<"请输入您要修改的学生的姓名:"<<endl;
cin>>name;
for(int h=0;h<i;h++)
{
if(strcmp(name,s[h]->name)==0)
{
char se;int ag,qq,te;
cout<<"请输入性别:"<<endl;
cin>>se;
cout<<"请输入年龄:"<<endl;
cin>>ag;
cout<<"电话号码:"<<endl;
cin>>te;
cout<<"QQ号码:"<<endl;
cin>>qq;
s[h]->sex=se;
s[h]->age=ag;
s[h]->telphone=te;
s[h]->QQ=qq;
cout<<"数据修改成功!";
break;
}
if (i == j)
{
cout<<"对不起!您要查询的学生不存在!"<<endl;
}
//else cout<<"您要修改的学生本来就不存在!请检查重新输入!"<<endl;
}
}
void tong::List() //(4)显示记录(List)
{
cout<<"本系统所有通讯录的数据如下:"<<endl;
if(i==0)
cout<<"管理系统中没有录入数据或者数据已经被删除!"<<endl;
for(int k=0;k<i;k++)
{
cout<<"姓名:"<<s[k]->name<<" "<<
"性别:"<<s[k]->sex<<" "<<"年龄:"<<s[k]->age
<<" "<<"电话号码:"<<s[k]->telphone<<" "<<"QQ号码:"
<<s[k]->QQ<<endl;
}
}
void tong::RearchN()
{
if(i==0)
cout<<"管理系统中没有录入数据或者数据已经被删除!"<<endl;
cout<<"请输入你要查询的学生姓名"<<endl;
cin>>name;
for(int j=0;j<i;j++)
{
if(strcmp(name,s[j]->name)==0)
{
cout<<"您要查询的学生是:"<<s[j]->name<<endl;
cout<<"性别: "<<s[j]->sex<<" "<<"年龄: "<<s[j]->age<<" "<<"电话号码:"<<s[j]->telphone
<<" "<<"QQ号码:"<<s[j]->QQ<<endl;
break;
}
// else
// cout<<"对不起!您要查询的学生不存在!"<<endl;
if (i == j)
{
cout<<"对不起!您要查询的学生不存在!"<<endl;
}
}
}
void tong::RearchT()
{
int n;
if(i==0)
cout<<"管理系统中没有输入数据!"<<endl;
cout<<"请输入你要查询的学生的电话"<<endl;
cin>>n;
for(int j=0;j<i;j++)
{
if(s[j]->telphone==n)
{
cout<<"您要查询的学生是:"<<s[j]->name<<endl;
cout<<" 性别: "<<s[j]->sex<<" "<<"年龄: "<<s[j]->age<<" "<<"电话号码:"<<s[j]->telphone
<<" "<<"QQ号码:"<<s[j]->QQ<<endl;
break;
}
//else cout<<"对不起!您要查询的学生不存在!"<<endl;
}
if (i == j)
{
cout<<"对不起!您要查询的学生不存在!"<<endl;
}
}
void tong::RearchQ()
{
int n;
if(i==0)
cout<<"管理系统中没有输入数据!"<<endl;
cout<<"请输入你要查询的学生的QQ"<<endl;
cin>>n;
for(int j=0;j<i;j++)
{
if(s[j]->QQ==n)
{
cout<<"您要查询的学生是:"<<s[j]->name<<endl;
cout<<" 性别: "<<s[j]->sex<<" "<<"年龄: "<<s[j]->age<<" "<<"电话号码:"<<s[j]->telphone<<" "<<"QQ号码:"<<s[j]->QQ<<endl;
break;
}
// else
// cout<<"对不起!您要查询的学生不存在!"<<endl;
}
if (i == j)
{
cout<<"对不起!您要查询的学生不存在!"<<endl;
}
}
void caozuo(int p)
{
tong t;
switch(p)
{
case 0:tSet();break;
case 1:tSet();break;
case 2:tDelete();break;
case 3:tAlter();break;
case 4:tList();break;
case 5:tRearchN();break;
case 6:tRearchT();break;
case 7:tRearchQ();break;
case 8:exit(0);break;
}
}
int main()
{
char w;
do
{
cout<<"请输入 *** 作代码(0 通讯录录入/1 增加人员/2 删除人员/3 修改数据/4 显示记录/ 5 按姓名查询/6 按电话查询/7 按QQ查询/8 退出)"<<endl;
int a;
cin>>a;
caozuo(a);
cout<<"您想继续进行其他 *** 作吗(y/n)"<<endl;
cin>>w;
}while(w=='y');
return 0;
} //利用while语句又回到了前面的循环
以上就是关于什么是程序设计全部的内容,包括:什么是程序设计、什么是程序什么是程序设计、计算机二级有哪些种类等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)