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.移动零

相关推荐
Scoful28 分钟前
快速用 uv 模拟发布一个 Python 依赖包到 TestPyPI 上,以及常用命令
开发语言·python·uv
老猿讲编程34 分钟前
汽车车载软件平台化项目规模颗粒度选择的一些探讨
c++·汽车
এ᭄画画的北北1 小时前
力扣-35.搜索插入位置
数据结构·算法·leetcode
clock的时钟1 小时前
c++第七天--继承与派生
开发语言·c++
cylat1 小时前
Day23 pipeline管道
人工智能·python·算法·机器学习
John_ToDebug1 小时前
Chrome 浏览器前端与客户端双向通信实战
前端·c++·chrome
scoone1 小时前
ESP32开发中Kconfig ninja cmake 三者之间的关系
c++
蓝桉~MLGT1 小时前
java高级——高阶函数、如何定义一个函数式接口类似stream流的filter
java·开发语言·python
lucky_jiexia2 小时前
leetcode刷题经验
算法·leetcode·哈希算法
Smile丶凉轩2 小时前
技术栈RabbitMq的介绍和使用
c++·分布式·rabbitmq