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

相关推荐
柴华松几秒前
GPU训练代码
开发语言·python
戊子仲秋3 分钟前
【LeetCode】每日一题 2024_9_19 最长的字母序连续子字符串的长度(字符串,双指针)
算法·leetcode·职场和发展
好兄弟给我起把狙6 分钟前
[Golang] Select
开发语言·后端·golang
Echo_Lee08 分钟前
C#与Python脚本使用共享内存通信
开发语言·python·c#
python之行19 分钟前
python 环境问题
开发语言·python
小林熬夜学编程20 分钟前
C++第五十一弹---IO流实战:高效文件读写与格式化输出
c语言·开发语言·c++·算法
月夕花晨37423 分钟前
C++学习笔记(30)
c++·笔记·学习
蠢蠢的打码25 分钟前
8584 循环队列的基本操作
数据结构·c++·算法·链表·图论
不是编程家32 分钟前
C++ 第三讲:内存管理
java·开发语言·c++
hakesashou34 分钟前
python怎么写csv文件
开发语言·python