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

相关推荐
##学无止境##1 小时前
从0到1吃透Java负载均衡:原理与算法大揭秘
java·开发语言·负载均衡
Desirediscipline1 小时前
#define _CRT_SECURE_NO_WARNINGS 1
开发语言·数据结构·c++·算法·c#·github·visual studio
范纹杉想快点毕业1 小时前
C语言550例编程实例说明
算法
知识即是力量ol1 小时前
多线程并发篇(八股)
java·开发语言·八股·多线程并发
尘缘浮梦1 小时前
协程asyncio入门案例 1
开发语言·python
ShineWinsu1 小时前
对于C++中map和multimap的详细介绍
c++·面试·stl·笔试·map·红黑树·multimap
没有bug.的程序员1 小时前
Lombok 深度进阶:编译期增强内核、@Data 与 @Builder 逻辑博弈及工业级避坑实战指南
java·开发语言·python·builder·lombok·data·编译器增强
guygg881 小时前
基于人工神经网络的彩色图像恢复 MATLAB实现
开发语言·计算机视觉·matlab
小O的算法实验室1 小时前
2026年SEVC SCI2区,面向无人机路径规划的领域专用算子进化算法,深度解析+性能实测
算法·论文复现·智能算法·智能算法改进
weixin_477271692 小时前
同人象:(两军停战谈判结盟的现场直播)马王堆帛书《周易》原文及甲骨文还原周朝生活现象《函谷门
算法·图搜索算法