[ create a new paste ] login | about

Link: http://codepad.org/KRyTZEQX    [ raw code | output | fork ]

C++, pasted on Jul 25:
#include<iostream>
#include<cmath>
using namespace std;

double calc_len(double x[],double y[])
{
  return sqrt(pow(x[0] - x[1], 2) + pow(y[0] - y[1], 2));
}

int
main()
{
  int             i;
  double x[2], y[2];
  for (i = 0; i < 2; i++) {
    cout << "x" << i + 1 << "=";
    cin >> x[i];
    cout << "y" << i + 1 << "=";
    cin >> y[i];
  }
  cout << "line is " << calc_len(x, y) << endl;
  return 0;
}


Output:
1
x1=y1=x2=y2=line is 8.91496e+303


Create a new paste based on this one


Comments: