1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
#include <iostream>
#include <fstream>
#include <cmath>
double distance(int, int, int, int);
double radius(int, int, int, int);
double circumference(int, int, int, int);
double area(int, int, int, int);
int main()
{
std::ifstream infile; // this should have been in main()
std::ofstream outfile; // this should have been in main()
int pointa = 5, pointb = -9, pointc = 12, pointd = 15;
std::cout << distance(pointa, pointb, pointc, pointd) << std::endl;
std::cout << radius(pointa, pointb, pointc, pointd) << std::endl;
/// blah blah blah
return 0;
}
double distance(int x1, int y1, int x2, int y2)
{
double distance;
distance = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1)); // fixed error
return distance;
}
double radius(int x1, int y1, int x2, int y2)
{
double radius;
radius = distance(x1, y1, x2, y2);
return radius;
}
double circumference(int x1, int y1, int x2, int y2)
{
double circumference, r;
r = radius(x1, y1, x2, y2);
circumference = 2 * 3.1416*r;
return circumference;
}
double area(int x1, int y1, int x2, int y2)
{
double area, r;
r = radius(x1, y1, x2, y2);
area = 3.1416*r*r;
return area;
}
|