// File: ftest1.C // // Testing the FArray class #include #include #include #include "farray.h" main(int argc, char *argv[]) { int size=0, seed=0 ; if (argc != 4) { cerr << "Usage: a.out size seed fname" << endl ; exit(1) ; } size = atoi(argv[1]) ; seed = atoi(argv[2]) ; if (size <= 0 || seed <= 0) { cerr << "Bad size or seed" << endl ; exit(1) ; } FArray A(size, seed) ; A.sort() ; if ( ! A.write(argv[3]) ) { cerr << "Write to file " << argv[3] << " failed." << endl ; exit(1) ; } if (A.check()) { cout << "Array is sorted" << endl ; } else { cout << "Array is NOT sorted" << endl ; } }