circle area

时间:2023-11-23 11:25:02

circle area

Github 链接:传送门


本次作业要求

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.


main.cpp

#include<iostream>
#include"print.h"
using namespace std;
int main()
{
double r;
cin >> r;
Printf(r);
return 0;
}

print.h

#include<iostream>
#define pi 3.1415926
using namespace std; void Printf(double r)
{
cout << pi*r*r << endl;
}

体会

懂得了在不用创建工程的情况下调用自己写好的头文件,这样能更好的让逻辑分块。进一步更好的解决逻辑复杂的问题

circle area