C++开学第一次作业(5.4)

开学第一次作业(5.4)

代码传送门

题目

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

主函数

#include <iostream>
#include"area.h"
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv)
{
	double r;
	cin >> r;
	cout << area(r) << endl;
	return 0;
}

外部函数

#include"area.h"
double area(double r)
{
	cout << r*r*PI ;
}

头文件

#include<cmath>
#include<iostream>
#define PI acos(-1)
using namespace std;
double area(double r);

原文地址:https://www.cnblogs.com/Anani-leaf/p/5463657.html