zoukankan      html  css  js  c++  java
  • 简单类

    Description

    实现一个名为SimpleCircle的简单类。其数据成员int *itsRadius为一个指向其半径值的指针,存放其半径值。(PI=3.14)

    设计对数据成员的各种操作:(1)半径设置和读取函数;(2)求面积;(3)求周长

    给出这个类的完整实现并测试这个类。
    Input

    圆的半径

    Output

    圆的半径

    周长

    面积

    Sample Input

    5

    Sample Output

    itsRadius=5

    circle=31.4

    Area=78.5

    #include<iostream>
    #include<cmath>
    const double pi=3.14;
    using namespace std;
    class SimpleCircle
    {
    private:
        int *Radius;
    public:
        SimpleCircle(int *r)
        {
         Radius=r;
        }
        double get()
        {
        cout<<"itsradius="<<*Radius<<endl;
        cout<<"circle="<<2*pi**Radius<<endl;
        cout<<"Area="<<pi**Radius**Radius<<endl;
        }
    };
    int main()
    {
        int r ;
        cin>>r;
        SimpleCircle newcircle(&r);
        newcircle.get();

    }

  • 相关阅读:
    LeNet && ModernCNN
    Fundamentals of Convolutional Neural Networks
    机器及其相关技术介绍
    学而后思,方能发展;思而立行,终将卓越
    贪心的区间问题
    基环树
    模板类
    存储问题
    大佬们的技巧
    exgcd
  • 原文地址:https://www.cnblogs.com/zeross/p/4525053.html
Copyright © 2011-2022 走看看