zoukankan      html  css  js  c++  java
  • 面向对象程序设计_课堂作业_01_Circle

    The 1st classwork of the C++ program

    题目:
    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 should be divided into two source files (.cpp). Hand in the source files and the head files which you create.
    github链接:Click Here

    看着英文题目好虚...不过题目还是挺简单的,就是求所输入半径的圆的面积,用到cin和cout,并把函数定义为外部函数,代码如下:

    Circle.h

    #pragma once
    #include <cmath>
    const double PI = acos(-1);
    
    /*extern*/ double CircleArea(double r);
    

    Circle.cpp

    #include "Circle.h"
    
    double CircleArea(double r)
    {
    	return PI * r * r;
    }
    

    main.cpp

    #include <iostream>
    #include "Circle.h"
    using namespace std;
    
    int main()
    {
    	double r;
    	cout << "Please input the radius of a circle : " << endl;
    	cin >> r;
    	cout << "The erea of this circle is : " << endl;
    	cout << CircleArea(r) << endl;
    
    //	system("pause");
    	return 0;
    }
    

    这样子就over了,在main函数里面还心虚的加了提示信息...毕竟第一次作业,完满的画上句号...画上句号。

  • 相关阅读:
    ibatis学习笔记
    记ibatis使用动态列查询问题(remapresults)
    jQuery(九)、ajax对象操作
    jQuery(八)、ajax
    jQuery(七)、效果和动画
    jQuery(六)、事件
    jQuery(五)、筛选
    jQuery(四)、文档处理
    jQuery(三)、属性、CSS
    jQuery(二)、选择器
  • 原文地址:https://www.cnblogs.com/monsterJang/p/5463736.html
Copyright © 2011-2022 走看看