问题描述
很抱歉的冠军,但我不知道热简要解释什么,我需要做的。
Sorry for the title but I don't know hot to explain briefly what I need to do.
我有这个predefined数组:
I have this predefined array :
string[] SkippedAreasArray = new string[] {"A", "B", "C", "D", "E", "F", "G",
"H", "I", "J", "K", "L", "M", "N", "O", "P", "Q"};
我们可以调用每个字母区
。我们有一个变量 NumberOfAreas
持有从0(零)的整数值到17这个数值的含义是这样的。如果 NumberOfAreas
= 5那么我们有字符串A,B,C,D,E
。如果 NumberOfAreas
= 3,那么我们有A,B,C
等。该字符串总是以A
,并按照字母顺序排列。
We can call each letter Area
. We have a variable NumberOfAreas
which holds an integer value from 0(null) to 17. The meaning of this value is this. If NumberOfAreas
= 5 then we have string "A", "B", "C", "D", "E"
. If NumberOfAreas
= 3 then we have "A", "B", "C"
and so on. The string always begins with "A"
and follow the alphabetical order.
用户输入的是所谓的 SkippedAreas
阵列。它可以包含随机字母,这是不能被复制,并在范围 AQ
。
The user input is the so called SkippedAreas
array. It can contains random letters, which can not be duplicated and are in the range A-Q
.
什么想法 - 如果我们有 SkippedAreas
阵列= A,C
和 NumberOfAreas
= 5或A,B,C,D,E
那么我们有保持 NumberOfAreas
等于5跳过信A
和C
并增加在未来的两封信,让 NumberOfAreas
成为─B,D,E, F,G
。
What is the idea - If we have SkippedAreas
array = "A", "C"
and NumberOfAreas
= 5 or "A", "B", "C", "D", "E"
then we have to keep the NumberOfAreas
equal to 5 by skipping the letter "A"
and "C"
and adding the next two letters so the NumberOfAreas
becomes- "B", "D", "E", "F", "G"
.
我们只能跳过一个字母(区)中已有的 NumerOfAreas
的范围内,例如,如果我们得到基例如当 NumerOfAreas
= 5和字符串A,B,C,D,E
我们只能跳过一个字母这是其中的5个字母之一。然而,通过跳过任何信件我们打开进入下一行,所以如果我们第一次跳过A
,我们可以自由使用F
下一轮,如果F
是部分从用户输入字符串 SkippedAreas
那么它的法律跳过F
键,打开G
。
We can only skip a letter(area) that is already in the range of NumerOfAreas
for example if we get the base example when NumerOfAreas
= 5 and the string is "A", "B", "C", "D", "E"
we can only skip a letter that is one of those 5 letters. However by skipping any letter we open access to the next in row so if the first time we skip "A"
we are free to use "F"
for the next round and if "F"
is part from the user input string SkippedAreas
then it's legal to skip "F"
and open "G"
.
我需要一个算法,我就可以验证用户输入。
I need an algorithm with which I will be able to validate the user input.
推荐答案
使用LINQ
var FilteredAreas =
ListOfAreas.Where(a => !SkippedAreas.Contains(a)).Take(NumberOfAreas);
这篇关于不要从一个数组的所有元素满足另一个字符串数组确定一定条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!