summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwjoe <joe@lc8n.com>2012-05-04 15:06:37 +0100
committerwjoe <joe@lc8n.com>2012-05-04 15:06:37 +0100
commit22ea1558213db7e1ef5172d6ddb73c6f0f24507f (patch)
treed2f87035c4b0daf14df3945d08a6bb2bc20e6faa
Initial commit v0.1
-rw-r--r--blarandom.cpp89
1 files changed, 89 insertions, 0 deletions
diff --git a/blarandom.cpp b/blarandom.cpp
new file mode 100644
index 0000000..b95c9a0
--- /dev/null
+++ b/blarandom.cpp
@@ -0,0 +1,89 @@
+/*
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+
+ Copyright 2012 Blatech <http://www.blatech.co.uk>
+ Author: Joe Robinson <joe@lc8n.com>
+
+ Changelog:
+
+ v1.0 - Initial release
+
+*/
+
+
+#include <iostream>
+#include <sstream>
+#include <climits>
+#include <string>
+
+#include <RandomLib/Random.hpp>
+
+int main() {
+
+ std::string version = "1.0";
+
+ RandomLib::Random r; // Create r
+ r.Reseed(); // and give it a unique seed
+ char input[100];
+
+ fgets(input, 100, stdin);
+ std::string strInput = input;
+ std::string args[10] = { "" };
+
+ std::istringstream iss(strInput);
+
+ int min = INT_MIN;
+ int max = INT_MIN;
+ int count = 1;
+
+ for(int i = 0; i < 3; i++) {
+ iss >> args[i];
+ }
+
+ if (!args[0].compare("-v")) {
+ std::cout << "v" << version << std::endl;
+ return 0;
+ }
+
+ if (args[2].empty()) {
+ count = 1;
+ } else {
+ count = atoi(args[2].c_str());
+ }
+
+ if (args[1].empty()) {
+ max = atoi(args[0].c_str());
+ min = 1;
+ } else {
+ max = atoi(args[1].c_str());
+ min = atoi(args[0].c_str());
+ }
+
+ if (args[0].empty()) {
+ min = 1;
+ max = 10;
+ }
+
+ for (int i = 0; i < count; i++) {
+ std::cout << r.IntegerC(min, max) << " ";
+ }
+
+ std::cout << std::endl;
+
+ return 0;
+
+}