Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- class HelloWorld {
- static string Format00(int x) {
- return ((x.ToString()).Length == 1) ? ("0" + x.ToString()) : x.ToString();
- }
- /*
- * sort:
- * 0 - none
- * 1 - asc
- * 2 - desc
- */
- const string path = "C:/inpu/";
- static bool createTests(string NameSet, int N = 2, string Type = "int", int Min = 2, int Max = 10, int LenMin = 4, int LenMax = 10, bool Repeat = true, string sort = "none", bool row = false) {
- if (Directory.Exists(path + NameSet))
- return false;
- if (N > 100)
- return false;
- Random rnd = new Random();
- for (int i = 0; i < N; i++) {
- //repeat
- //sort
- //Type
- int tests = rnd.Next(LenMin, LenMax);
- double[] toput = new double[tests];
- if (Repeat) {
- for (int j = 0; j < tests; j++) {
- toput[j] = Type == "int" ? rnd.Next(Min, Max) : (rnd.Next(Min * 100, Max * 100) / 100.0);
- }
- //List<int> res = new List<int>(numbers);
- } else {
- //Dictionary<int, bool> numbers = new Dictionary<int, bool>();
- //foreach (var pair in numbers.OrderBy(pair => pair.Value))
- //{
- // Console.WriteLine("{0} - {1}", pair.Key, pair.Value);
- //}
- //List sortedList = new ArrayList(yourHashSet);
- //Collections.sort(sortedList);
- //numbers = (numbers.OrderBy(key => key.Key)).ToDictionary(key => key.Key, key => key.Value);
- //List<int> hList = hset.ToList();
- HashSet<double> numbers = new HashSet<double>();
- while (numbers.Count < tests) {
- numbers.Add(Type == "int" ? rnd.Next(Min, Max) : (rnd.Next(Min * 100, Max * 100) / 100.0));
- }
- List<double> numm = new List<double>(numbers);
- for (int j = 0; j < tests; j++) {
- toput[j] = numm[j];
- }
- }
- if (sort != "none")
- Array.Sort(toput);
- if (sort == "desc")
- Array.Reverse(toput);
- //StreamReader sr = new StreamReader("C:/inpu/in.txt");
- Directory.CreateDirectory(path + NameSet);
- StreamWriter sw = new StreamWriter(path + NameSet +"/test" + Format00(i + 1) + ".txt", true);
- sw.WriteLine(tests);
- for (int j = 0; j < tests; j++) {
- if (row)
- sw.Write((Type == "int" ? (int)toput[j] : toput[j]) + " ");
- else
- sw.WriteLine(Type == "int" ? (int)toput[j] : toput[j]);
- }
- sw.Close();
- }
- return true;
- }
- static void Main() {
- //NameSet, int N = 2, string Type = "int", int Min = 2, int Max = 10, int LenMin = 4, int LenMax = 10, bool Repeat = true, string sort = "none", bool row = false
- createTests("Long test", 10, "double", -100000, 100000, 5, 90, false, "none", false);
- //createTests("baaa", 4, "int", 2, 10, 4, 10, false, "desc", true);
- //createTests("rrbaaa", 4, "int", 2, 10, 4, 10, true, "none", true);
- Console.ReadKey();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement