include<iostream>
using namespace std;
class Shape {
public:
Shape(double a = 0, double p = 0);
vi
2018-1-6 10:31
请先登录。
老师我昨天忘记交作业了,抱歉
12_01
#include
using namespace std;
class Shape {
public:
Shape(double a = 0, double p = 0);
virtual void displayArea() = 0;
virtual void displayPerimeter() = 0;
protected:
double m_dArea;
double m_dPerimeter;
};
class Circle:public Shape
{
public:
Circle(double r = 0);
virtual void displayArea();
virtual void displayPerimeter();
private:
double m_dR;
};
class Rectangle :public Shape
{
public:
Rectangle(double l = 0, double w = 0);
virtual void displayArea();
virtual void displayPerimeter();
private:
double m_dLength;
double m_dWidth;
};
Shape::Shape(double a, double p)
{
m_dArea = a;
m_dPerimeter = p;
}
Circle::Circle(double r)
{
m_dR = r;
}
void Circle::displayArea() {
cout include
using namespace std;
template
inline void mySwap(T &a, T&b)
{
T temp;
temp = b;
b = a;
a = temp;
}
template
void bubbleSort(T*const arr, int size)
{
int i,j;
for (i = 0; i *(arr + j))
{
T temp;
temp = *(arr + j);
*(arr + j) = *(arr + i);
*(arr + i) = temp;
}
}
}
}
template
void printResult(T*const arr, int size)
{
int i;
for (i = 0; i (arri, 10);
double arrd[10] = { 4.4,2.2,5.5,7.7,9.9,1.1,3.3,8.8,0,6.6 };
bubbleSort(arrd, 10);
printResult(arrd, 10);
char arrc[10] = "aefdighcb";
bubbleSort(arrc, strlen(arrc));
printResult(arrc, strlen(arrc));
return 0;
}
展开