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