A , B b ( , ).
total ((a * b) + 1) core: A B. , b A, * b. Last +1 , .
, . , true
, else false
. A [0], . , B A [0]. A [0] B [0] , A [0] B [1] , OR . , test()
, , :
public static bool test (int aElement, int bElement)
{
return aElement == bElement;
}
A [1], A [2].. A [a-1] .
, :
(test(A[0], B[0]) || test(A[0], B[1])...) && (test(A[1], B[0]) || test(A[1], B[1])... )
, Main()
:
public void Main (string[] args)
{
//Read A and B arrays and create the next line dynamically
var allPresent = (test(A[0], B[0]) || test(A[0], B[1]) ||... test(A[0], B[b-1]))
&& (test(A[1], B[0]) || test(A[1], B[1]) ||... test(A[1], B[b-1]))
.
.
.
&& (test(A[a-1], B[0]) || test(A[a-1], B[1]) ||... test(A[a-1], B[b-1]))
Console.WriteLine("All Elements {0}", (allPresent ? "Found" : "Not Found"));
}
test(A[k], B[l])
, O (1) .