#if 0 #include #include // This program plots a sequence of "moves" // of the form (1.2, 3.4) // stop when read in a 'q' using namespace std; struct Point { double x, y; }; Point operator+(Point p1, Point p2) { Point p3; p3.x = p1.x + p2.x; p3.y = p1.y + p2.y; return p3; } Point operator/ (Point p, int factor) { p.x = p.x / factor; p.y = p.y / factor; return p; } Point calcMidpoint(Point p1, Point p2) { Point mid = (p1 + p2) / 2; return mid; } int main() { // Initialize location Point loc; Point move; loc.x = loc.y = 0; // Read in bunch of moves while(true) { // Read one move char junk; cin >> junk; if (junk == 'q') { break; } cin >> move.x >> junk >> move.y >> junk; // Compute midpoint between 'move' and 'loc' Point mid = calcMidpoint(loc, move); cout << " mid is: " << mid.x << " , " << mid.y << endl; // Update position loc = loc + move; // Output position cout << "Now at: " << loc.x << " , " << loc.y << endl; } return 0; } #endif