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
|
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
double sword(double x, double y, double& itmes);
double heart(double x, double y);
double triforce(double x, double y);
int main()
{
double items[3][2]=
{
{ 5.0, 3.0 }, //Sword
{ -3.125, 0}, //Heart
{ 1.5, 8.1 } //TriForce
};
double X, Y;
cout<<"== Zelda (version 0.000001) ==\n";
cout<<"What is the position of our hero, Link?\n";
cout<<"Enter X and Y coordinates separated by a space\n";
cin>>X>>Y;
//cout<<"Sword is at X= "<<items[0][0]<<"Y= "<<items[0][1];
cout<<"Sword is at (5.0, 3.0). Distance from :"<<sword(X, Y, items);
return 0;
}
double sword(double x, double y, double& items)
{
double tx, ty, ptx, pty, Dist;
tx = items[0][0]-X;
ty = items[0][1]-Y;
ptx = pow(tx, 2);
pty = pow(ty, 2);
Dist = sqrt(ptx +pty);
return Dist;
}
|