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

相关推荐
牛奔7 小时前
Go 如何打印调试深层或嵌套的结构体
开发语言·后端·golang
m沐沐7 小时前
【深度学习】YOLOv2目标检测算法——改进点、网络结构与聚类先验框解析
人工智能·pytorch·深度学习·算法·yolo·目标检测·transformer
不会就选b7 小时前
算法日常・每日刷题--<链表>3
数据结构·算法·链表
geovindu8 小时前
go: Iterative Algorithms
开发语言·后端·算法·golang·迭代算法
学逆向的8 小时前
汇编——JCC指令
开发语言·汇编·网络安全
mayaairi9 小时前
JS循环语句深度解析:嵌套for、while与do...while
开发语言·前端·javascript
kite01219 小时前
Go语言Map深度解析与最佳实践
开发语言·后端·golang
Zachery Pole10 小时前
CCF-CSP备战NO.7【队列】
算法
闪电悠米10 小时前
力扣hot100-48.旋转图像-转置翻转详解
算法·leetcode·职场和发展
满天星830357711 小时前
【算法】最长递增子序列(三种解法)
算法