Advertisement
Guest User

Untitled

a guest
Sep 16th, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. // main() calls both findDistance() and test() correctly so they don't need to be shown.
  2. // Note: This is only a section of the full code as it is the only relevant part.
  3.  
  4. double findDistance(float x1, float y1, float x2, float y2) {
  5.     double distanceTotal = sqrt( pow( 2, (x2-x1) ) + pow( 2, (y2-y1 ))); // This line doesn't work with assert values.
  6.     //double distanceTotal = (x2-x1) + (y2-y1); // This line works with assert values.
  7.     return distanceTotal;
  8. }
  9.  
  10. void test() {
  11.     assert(findDistance(4, 3, 5, 1) - 2.23607 <= epsilon); // Need to use assert two more times. Look it up.
  12.     assert(findDistance(2, 4, 2, 4) <= 1.00);
  13.     assert(findDistance(4, 4, 4, 4) <= 1.00);
  14.  
  15.     cout << "all tests passed..." << endl;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement