#include #include #include #include using namespace std; int generatePoints() { ofstream myfile; string input; int totalNumber; cout << "Please enter number of points: "; getline(cin, input); totalNumber = atoi(input.c_str()); string fileName = "points" + input + ".txt"; myfile.open(fileName.c_str()); if (myfile.is_open()) { int biggestX; int biggestY; myfile << totalNumber << endl; cout << "Largest X value: "; getline(cin, input); biggestX = atoi(input.c_str()); cout << "Largest Y value: "; getline(cin, input); biggestY = atoi(input.c_str()); for (int i = 0; i < totalNumber; i++) { float xcor = static_cast(rand() / static_cast (RAND_MAX/biggestX)); float ycor = static_cast (rand() /static_cast (RAND_MAX/biggestY)); stringstream xcorStr; xcorStr << xcor; stringstream ycorStr; ycorStr << ycor; string line = xcorStr.str() + " " + ycorStr.str() + "\n"; cout << line; myfile << line; } myfile.close(); } else { cout << "Can't open the file!" << endl; } return 0; } /* * */ int main() { generatePoints(); return 0; }