Skip to content

Instantly share code, notes, and snippets.

@edhedges
Created November 29, 2011 18:22
Show Gist options
  • Save edhedges/1405825 to your computer and use it in GitHub Desktop.
Save edhedges/1405825 to your computer and use it in GitHub Desktop.
Simple team randomizer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Teams
{
class Program
{
static void Main(string[] args)
{
/*
Right now the program is set to static 10 name entries for two teams of 5 people. It can be modified easily by changing the number 10
to another number that can be evenly divided into two teams. You will also need to change any 5 to the new team size as well as enter
more names to randomize.
*/
int[] y = new int[10];
Random random = new Random();
bool[] array1 = new bool[10];
for (int i = 0; i < 10; i++)
{
array1[i] = true;
}
/*
Assign people number or replace the numbers with the names you would like.
*/
string[] array = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" };
Console.WriteLine("Team One: \n");
int count = 0;
while(count < 5)
{
int x = random.Next(10);
if (array1[x])
{
Console.Write(array[x].ToString() + "\n");
array1[x] = false;
count++;
}
}
Console.WriteLine("\nTeam Two: \n");
count = 0;
while(count < 5)
{
int x = random.Next(10);
if(array1[x]){
Console.Write(array[x].ToString() + "\n");
array1[x] = false;
count++;
}
}
Console.WriteLine("\nPress any key to terminate the program.");
Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment