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函数里面还心虚的加了提示信息...毕竟第一次作业,完满的画上句号...画上句号。

  • 相关阅读:
    记一次MD5妙用
    go执行外部应用
    Go语言中的HTTP
    Go语言中的UDP应用
    Go学习
    Element-ui学习使用
    Vue学习
    BootCDNApi使用记录
    jquery.easypiechart.js简介
    jquery.gritter.js简介
  • 原文地址:https://www.cnblogs.com/monsterJang/p/5463736.html
Copyright © 2011-2022 走看看