Home > Net >  Please answer the.net rota
Please answer the.net rota

Time:09-27

.net rota don't cycle there are five people {A, B, C, D, E} one person on duty one day, as long as A to on duty on Monday, and other four every day except Monday on duty cycle, cycle for A year

CodePudding user response:

有点难度

CodePudding user response:

List The users=new List {" B ", "C", "D", "E"};
List UsersTemp=new List (a);
The Random rd=new Random ();
for (int i=0; i <365; I++)
{
DateTime date=DateTime. Now. AddDays (I);
Int day=(int) date. DayOfWeek;
If (day==1)
{
//A watch
}
Else if (day & gt; 1 & amp; & Day & lt; 6)
{
If (usersTemp. Count==0)
{
UsersTemp. AddRange (users);
}
//get a random number
Int n=rd. Next (0, usersTemp. Count - 1);
//get the watch
String user=usersTemp [n].
//remove have typography
UsersTemp. RemoveAt (n);
}
}

CodePudding user response:

Since the ceiling for a year so not much data
Directly generated data array to remove 365 days on Monday for scheduling in merge sort through time
done

CodePudding user response:

Public static void (aa)
{
List The users=new List {" B ", "C", "D", "E"};
List UsersTemp=new List (a);
List ValueList=new List (a);
Bool isOne=true;
for (int i=0; i <365; I++)
{
DateTime date=DateTime. Now. AddDays (I);
Int day=(int) date. DayOfWeek;
If (day==1)
{
//A watch
UsersTemp. Add (" a ");
//the first after the first of the values in the array the back
if (! IsOne)
{
String value=https://bbs.csdn.net/topics/users [0];
Users. The RemoveAt (0);
Users. The Add (value);
}
}
Else if (day & gt; 1 & amp; & Day & lt; 6)
{
IsOne=false;
String value=https://bbs.csdn.net/topics/users [0];
UsersTemp. Add (the users/day - 2);

}
}
}
  •  Tags:  
  • C#
  • Related