github链接:

https://github.com/deepYY/object-oriented/tree/master/Circle

作业题目

Create a program that asks for the radius of a circle and prints the area of that circle, using cin and cout. The whole program shouldbedividedinto two source files (.cpp). Hand in the source files and the head files which youcreate

代码如下

main.cpp

#include <iostream>
#include<stdlib.h>
#include "circle_area.h"
using namespace std;
int main(int argc, char** argv)
{
double r,area;
Circle_area ca;
cin >> r;
area = ca.get_area(r);
cout << "S=" << area << endl;
return 0;
}

circle_area.h

#ifndef CIRCLE_AREA_H
#define CIRCLE_AREA_H
#define pi 3.14
#include <iostream>
class Circle_area
{
public:
double get_area(double r);
};
#endif

circle_area.cpp

#include "circle_area.h"
#include<stdlib.h>
#include <iostream>
double Circle_area::get_area(double r)
{
return (r*r*pi);
}

C++课堂作业(1)的更多相关文章

  1. 栋哥你好,让我们回顾最初认识C++的时候(课堂作业)

    计算器的第一步,至今还记记忆犹新,本次的课堂作业,便是那个框架.闲话少叙,代码如下传送门: Main.cpp #include "stdafx.h" #include<ios ...

  2. 20155213 第十二周课堂作业MySort

    20155213 第十二周课堂作业MySort 作业要求 模拟实现Linux下Sort -t : -k 2的功能 参考 Sort的实现 提交码云链接和代码运行截图 初始代码 1 import java ...

  3. 课堂作业-Bag类的实现

    课堂作业-Bag类的实现 要求: 代码运行在命令行中,路径要体现学号信息,IDEA中,伪代码要体现个人学号信息 参见Bag的UML图,用Java继承BagInterface实现泛型类Bag,并对方法进 ...

  4. Java课程课堂作业代码

    前言 本文章只是单纯记录课堂老师布置的课堂作业代码,题目都比较简单,所以没有写解题思路,相信大家都能理解,当然其中有的解法和代码不是最优的,当时只是为了完成题目,后来也懒得改了,如果有不恰当或者不正确 ...

  5. Java课堂作业详解

    今天的Java课堂留下了一个作业:使用Eclipse编写一个程序,使输入的两个数进行加和,并且输出他们的和.对于这个题目,我们首先可以把它分解成为三个不同的小步骤 第一步就是输入这两个数,因为我们无需 ...

  6. 百度前端学院js课堂作业合集+分析(更新中...)

    第一课:简陋的登录框 <!DOCTYPE html> <html lang="en"> <head> <meta charset=&quo ...

  7. OSLab课堂作业1

        日期:2019/3/16 作业:实现命令cat, cp, echo. myecho命令 #include <stdio.h> int main(int argc, char *ar ...

  8. 面向对象程序设计_课堂作业_01_Circle

    The 1st classwork of the C++ program 题目: Create a program that asks for the radius of a circle and p ...

  9. C++ 课堂作业1.0

    c++第一次课堂作业点这里 题目要求:输入半径,计算圆的面积,在调用外部函数,无需使用类.

  10. 第一次课堂作业之Circle

    1.问题描述: Create a program that asks for the radius of a circle and prints the area of that circle, us ...

随机推荐

  1. RocketMQ异常

    rocketMQ下载下来的时候,bin目录下有mqbroker.exe和mqnamesrv.exe两个可执行文件,双击执行都可以成功启动:

  2. .net core 导出excel

    1.使用NuGet 安装 EPPlus.Core, 2.代码如下 using OfficeOpenXml; using OfficeOpenXml.Style; public IActionResul ...

  3. [javaSE] 集合工具类(Collections-sort)

    java为我们提供了一个集合的工具类,方便我们对集合进行操作,里面的方法都是静态方法. Collections.sort()方法,参数:List<T>集合对象,这个对象带着泛型,是为了保证 ...

  4. WPF月视图控件

    简介 在做一个应用时,需要做成日历月视图的形式.自己做较麻烦,于是上网找找看,在CodeProject上发现了这个Quick and Simple WPF Month-view Calendar,可是 ...

  5. 六、yarn运行模式

    简介 spark的yarn运行模式根据Driver在集群中的位置分成两种: 1)yarn-client 客户端模式 2)yarn-cluster 集群模式 yarn模式和standalone模式不同, ...

  6. Spring Boot学习笔记(五)整合mybatis

    pom文件里添加依赖 <!-- 数据库需要的依赖 --> <dependency> <groupId>org.mybatis.spring.boot</gro ...

  7. Spring动态注册bean实现动态多数据源

    Spring动态注册bean实现动态多数据源 http://blog.csdn.net/littlechang/article/details/8071882

  8. Fill Table Row(it’s an IQ test question)

    Here is a table include the 2 rows. And the cells in the first row have been filled with 0~4. Now yo ...

  9. MySql的InnoDB存储引擎--索引

    索引分类: 1.聚集索引:索引顺序与物理顺序一致. MySql 的 InnoDB 中,主键索引就是聚集索引.好处是,进行搜索的时候,因为索引和物理顺序一致,所以找数据的时候更快. 2.非聚集索引:索引 ...

  10. Bzoj3197: [Sdoi2013]assassin

    题面 传送门 Sol 套路:找出重心,如果有两个就新建一个点 然后把这棵树hash一下 设\(f[i][j]\)表示第一颗树到\(i\)第二棵树到\(j\),子树\(i,j\)同构的付出的最小代价 转 ...