amh1k/daa-algorithm-visualizer
0
1// Test Data Generator for Q2 - Generates 10 files for each algorithm (100-1000 size)2#include <iostream>3#include <fstream>4#include <random>5using namespace std;6 7double randDouble(double min, double max) {8 static mt19937 gen(random_device{}());9 return uniform_real_distribution<>(min, max)(gen);10}11 12char randDigit() {13 static mt19937 gen(random_device{}());14 return '0' + uniform_int_distribution<>(0, 9)(gen);15}16 17int main() {18 int sizes[] = {100, 150, 200, 300, 400, 500, 600, 700, 850, 1000};19 20 // Generate Closest Pair tests21 for (int i = 0; i < 10; i++) {22 ofstream f("test_data/closest_pair/test_" + to_string(i+1) + "_n" + to_string(sizes[i]) + ".txt");23 f << sizes[i] << "\n";24 for (int j = 0; j < sizes[i]; j++)25 f << randDouble(-1000, 1000) << " " << randDouble(-1000, 1000) << "\n";26 f.close();27 cout << "Created closest_pair test " << (i+1) << " (n=" << sizes[i] << ")\n";28 }29 30 // Generate Integer Multiplication tests31 for (int i = 0; i < 10; i++) {32 ofstream f("test_data/integer_multiplication/test_" + to_string(i+1) + "_d" + to_string(sizes[i]) + ".txt");33 string num1, num2;34 num1 += randDigit(); if(num1[0]=='0') num1[0]='1';35 num2 += randDigit(); if(num2[0]=='0') num2[0]='1';36 for (int j = 1; j < sizes[i]; j++) {37 num1 += randDigit();38 num2 += randDigit();39 }40 f << num1 << "\n" << num2 << "\n";41 f.close();42 cout << "Created integer_mult test " << (i+1) << " (d=" << sizes[i] << ")\n";43 }44 45 cout << "\nDone! 20 test files created.\n";46 return 0;47}48 