Computer Science- Algorithms

Gm see
create_input.cpp

// // create_input.cpp // // // Created by Bhowmick, Sanjukta on 1/20/20. // #include <iostream> #include <fstream> #include <stdio.h> #include <time.h> using namespace std; int main(int argc, char *argv[]) { if ( argc < 3) { cout << "Two inputs needed: First the number of entries; Second the range from -r to r \n"; return 0; } int n=atoi(argv[1]); int r=atoi(argv[2]); ofstream myfile; int v; int q; myfile.open ("input.txt"); srand(time(NULL)); for (int i=0;i<n;i++) { /* generate number between 0 and n: */ v = rand() % (r+1) ; if(v==0){q=1;} else{ q=rand()%3; } if(q==0) myfile << -v <<"\n"; else myfile << v <<"\n"; } myfile.close(); return 0; }