/* FILE: randStomp2x3over2xn.cpp last change: 30-Sep-2013 author: Romeo Rizzi * This program generates a random 2xn Stomp stripe of 2 values: 0,1. * Usage syntax: * > randStomp2x3over2xn stomp n seed * * Usage example: * > randStompField 20 1 1 1 1 0 0 777 */ #include #include #include #include using namespace std; int RandNumber(int min, int max) { /* returns an integer in [min, max] * see Stroustrup "The c++ Programming Language" 3th edition pg. 685 * for comments on the following manipulation choice. * In particular, considerations on the bad quality of low bits come into account. */ return min + (int) ( (max-min +1) * (double( rand()-0.000000000001 ) / RAND_MAX ) ); } int main(int argc, char** argv) { srand(time(NULL)); int n = atoi(argv[1]); int s11 = atoi(argv[2]); int s12 = atoi(argv[3]); int s13 = atoi(argv[4]); int s21 = atoi(argv[5]); int s22 = atoi(argv[6]); int s23 = atoi(argv[7]); if(argc > 8) srand( atoi(argv[8]) ); cout << n << endl; cout << s11 << " " << s12 << " " << s13 << endl; cout << s21 << " " << s22 << " " << s23 << endl; for(int i = 0; i < 2; i++) { for(int j = 0; j < n; j++) cout << RandNumber(0, 1) << " "; cout << endl; } return 0; }