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

相关推荐
CS创新实验室5 分钟前
《计算机网络》深入学:海明距离与海明码
计算机网络·算法·海明距离·海明编码
WW_千谷山4_sch7 分钟前
MYOJ_10599:CSP初赛题单10:计算机网络
c++·计算机网络·算法
BHXDML9 分钟前
JVM 深度理解 —— 程序的底层运行逻辑
java·开发语言·jvm
Wang's Blog12 分钟前
Nodejs-HardCore: 深入解析DBF文件之二进制文件处理指南
开发语言·nodejs
hoiii18712 分钟前
基于LSB匹配的隐写术MATLAB实现程序
开发语言·matlab
J2虾虾19 分钟前
Java使用的可以使用的脚本执行引擎
java·开发语言·脚本执行
幻云201022 分钟前
Next.js指南:从入门到精通
开发语言·javascript·人工智能·python·架构
老马识途2.024 分钟前
java处理接口返回的json数据步骤 包括重试处理,异常抛出,日志打印,注意事项
java·开发语言
YuTaoShao28 分钟前
【LeetCode 每日一题】1458. 两个子序列的最大点积——(解法三)状态压缩
算法·leetcode·职场和发展
CCPC不拿奖不改名30 分钟前
网络与API:从HTTP协议视角理解网络分层原理+面试习题
开发语言·网络·python·网络协议·学习·http·面试