Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace GeneratorVariants
- {
- class Program
- {
- public static List<string> numTasks = new List<string>
- {
- "120",
- "121",
- "122",
- "123",
- "124",
- "125",
- "126",
- "127",
- "128",
- "129а",
- "120б",
- "120в",
- "120г",
- "120д",
- "120е",
- "120ж",
- "120з",
- "120и",
- "120к",
- "120л",
- "120м",
- "120н",
- "120о",
- "130а",
- "130б",
- "130в",
- "130г",
- "130д",
- "130е",
- "130ж",
- "130з",
- "130и",
- "130к",
- "130л",
- "130м",
- "130н",
- "130о",
- "130п",
- "130р",
- "131",
- "132",
- "133",
- "134",
- "135"
- };
- public static int countTasks = 5;
- public static int countVariants = 30;
- public static int[] indexTasks;
- static void Main(string[] args)
- {
- for (int i = 0; i < countVariants; i++) {
- indexTasks = new int[countTasks];
- Console.WriteLine($"Вариант {i+1}:");
- for (int j = 0; j < indexTasks.Length; j++)
- {
- indexTasks[j] = ChoiseNum();
- if (j == indexTasks.Length - 1)
- Console.Write($"{numTasks[indexTasks[j]]}");
- else
- Console.Write($"{numTasks[indexTasks[j]]}, ");
- }
- Console.WriteLine();
- }
- }
- static int ChoiseNum()
- {
- bool isAdd = false;
- int num = 0;
- Random rnd = new Random();
- do
- {
- num = rnd.Next(0, numTasks.Count);
- isAdd = CheckAvailability(num);
- } while (!isAdd);
- return num;
- }
- static bool CheckAvailability(int index)
- {
- bool result = true;
- for(int i = 0; i < indexTasks.Length; i++)
- {
- if(index == indexTasks[i])
- {
- result = false;
- break;
- }
- }
- return result;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment