c++刷题

17.电话号码的组合

来源于题解思路:

继承

CC14 KiKi设计类继承

复制代码
#include <iostream>
#include <memory>
using namespace std;
class Shape{
private:
    int x;
    int y;
};

class Rectangle:public Shape
{
public:
    Rectangle(int length,int width)
        :Shape()
        ,_length(length)
        ,_width(width)
        {}
    void GetArea()
    {
        cout<<_length*_width<<endl;
    }
protected:
    int _length;
    int _width;
};
class Circle:public Shape{
public:
    Circle(int r)
        :Shape()
        ,_r(r)
        {}
    void GetArea()
    {
        cout<<3.14*_r*_r<<endl;
    }
private:
    int _r;
};
class Square:public Rectangle
{
public:
    Square(int len)
        :Rectangle(len,len)
        {}
    void GetArea()
    {
        cout<<_length*_length<<endl;
    }

};
int main() {
    int length=0,width=0;
    cin>>length>>width;
   Rectangle ret(length,width);
   ret.GetArea();
   int r;
   cin>>r;
   Circle cir(r);
   cir.GetArea();

   int len;
   cin>>len;
   Square le(len);
   le.GetArea();
}
// 64 位输出请用 printf("%lld")

双指针算法

283.移动零

相关推荐
这就是佬们吗2 分钟前
初识 docker [上]
java·开发语言·笔记·docker·容器
MediaTea12 分钟前
Python 库手册:doctest 文档测试模块
开发语言·python·log4j
hweiyu0035 分钟前
R语言简介(附电子书资料)
开发语言·r语言
hweiyu0037 分钟前
R语言常用扩展包
开发语言·r语言
明明如月学长1 小时前
什么你不知道 Cherry Studio 有快捷助手?
算法
拳里剑气1 小时前
C语言:顺序表(上)
c语言·开发语言·数据结构·学习方法
Vegetable_Dragon1 小时前
数论1.01
算法
王者鳜錸1 小时前
PYTHON从入门到实践-15数据可视化
开发语言·python·信息可视化
Star在努力1 小时前
15-C语言:第15天笔记
c语言·笔记·算法
杨航 AI1 小时前
ADB+Python控制(有线/无线) Scrcpy+按键映射(推荐)
开发语言·python·adb