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 分钟前
UVa 1597 Searching the Web
数据结构·算法
云泽8087 分钟前
排序算法实战:从插入排序到希尔排序的实现与性能对决
算法·排序算法
多恩Stone18 分钟前
【3DV 进阶-5】3D生成中 Inductive Bias (归纳偏置)的技术路线图
人工智能·python·算法·3d·aigc
恋恋西风19 分钟前
Qt 打开文件列表选择文件,实现拖拽方式打开文件,拖拽加载
开发语言·qt
yong158585534323 分钟前
1. Linux C++ muduo 库学习——库的编译安装
linux·c++·学习
闲人编程31 分钟前
使用Python进行量化交易入门
开发语言·python·统计分析·lambda·量化·codecapsule
.ZGR.1 小时前
蓝桥杯高校新生编程赛第二场题解——Java
java·算法·蓝桥杯
blammmp1 小时前
算法专题十七:穷举vs暴搜vs深搜vs回溯vs剪枝
算法·机器学习·剪枝
mit6.8241 小时前
回溯剪枝trick
c++
移远通信1 小时前
常见问题解答
开发语言·php