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 49 50 51 52 53 54
|
#include <iostream>
#include <string>
#include <cctype>
#include <sstream>
using namespace std;
struct Point{
int x;
int y;
int x2;
int y2;
}name;
Point midpoint(const Point& a, const Point& b)
{
Point vec;
vec.x = (a.x + b.x) / 2;
vec.y = (a.y + b.y) / 2;
return vec;
}
int main()
{
string mystr;
int n;
for (n = 0; n < 100; n++)
{
cout << "Enter 1st Point(x,y): ";
getline (cin, name.x, name.y); //I seem to be getting an error here.
cout << "Enter 2nd Point(x,y): ";
getline (cin, name.x2, name.y2);
cout << "midpoint between" << name.x << ", " << name.y << " and " << name.x2 << ", " << name.y2 << " is " << vec <<endl;
cout << "Do you want to continue?: ";
cin >> choice;
char choice;
if (choice == 'y')
{
cout << "Enter 1st Point(x,y): ";
getline (cin, name.x, name.y);
cout << "Enter 2nd Point(x,y): ";
getline (cin, name.x, name.y);
cout << "Do you want to continue?: ";
cin >> choice;
}
else if (choice == 'n')
{
break;
}
}
}
|