class Program
{
static void Main(string[] args)
{
string start = DateTime.Now.ToString(); ;
Laji laji = new Laji();
laji.D = 5;
for (int o = 0; o < 10; o++)
for (int n = 0; n < 10; n++)
for (int a = 0; a < 10; a++)
for (int l = 0; l < 10; l++)
for (int g = 0; g < 10; g++)
{
laji.O = o;
laji.N = n;
laji.A = a;
laji.L = l;
laji.G = g;
if (laji.checkSingle() &&
(laji.donald.getVal() + laji.gerald.getVal() == laji.robert.getVal()))
{
Console.WriteLine(laji.getVal());
string end = DateTime.Now.ToString();
Console.WriteLine(start+"--"+end);
Console.ReadKey();
}
}
}
class Laji
{
public Donald donald = new Donald();
public Gerald gerald = new Gerald();
public Robert robert = new Robert();
private int d = 0;
private int o = 0;
private int n = 0;
private int a = 0;
private int l = 0;
private int g = 0;
private int e = 0;
private int r = 0;
private int b = 0;
private int t = 0;
public int D
{
get { return d; }
set
{
donald.D1 = donald.D2 = gerald.D = d = value;
gerald.R = robert.R1 = robert.R2 = r = getR(D, G, A, L);
robert.B = b = getB(N, D, G, A, L);
robert.T = t = getT(D);
}
}
public int O
{
get { return o; }
set
{
if (checkO(O, A, L))
donald.O = robert.O = o = value;
}
}
public int N
{
get { return n; }
set
{
donald.N = n = value;
robert.B = b = getB(N, D, G, A, L);
}
}
public int A
{
get { return a; }
set
{
donald.A = gerald.A = a = value;
gerald.E = robert.E = e = getE(A, L);
gerald.R = robert.R1 = robert.R2 = r = getR(D, G, A, L);
robert.B = b = getB(N, D, G, A, L);
}
}
public int L
{
get { return l; }
set
{
donald.L = gerald.L = l = value;
gerald.E = robert.E = e = getE(A, L);
gerald.R = robert.R1 = robert.R2 = r = getR(D, G, A, L);
robert.B = b = getB(N, D, G, A, L);
}
}
public int G
{
get { return g; }
set
{
gerald.G = g = value;
gerald.R = robert.R1 = robert.R2 = r = getR(D, G, A, L);
robert.B = b = getB(N, D, G, A, L);
}
}
public bool checkO(int o, int a, int l)
{
return o == (o + getE(a, l)) % 10;
}
public int getE(int a, int l)
{
return (2 * a + (4 < l ? 1 : 0)) % 10;
}
public int getR(int d, int g, int a, int l)
{
return (d + g + (9 < O + getE(a, l) ? 1 : 0)) % 10;
}
public int getB(int n, int d, int g, int a, int l)
{
return (n + getR(d, g, a, l) + (4 < a ? 1 : 0)) % 10;
}
public int getT(int d)
{
return (2 * d) % 10;
}
public bool checkSingle()
{
int[] arr = new int[] { d, o, n, a, l, g, e, r, b, t };
for (int i = 0; i < arr.Length; i++)
{
for (int j = 0; j < arr.Length; j++)
{
if (i != j && arr[i] == arr[j])
{
return false;
}
}
}
return true;
}
public string getVal()
{
return "d-" + d
+ ",o-" + o
+ ",n-" + n
+ ",a-" + a
+ ",l-" + l
+ ",g-" + g
+ ",e-" + e
+ ",r-" + r
+ ",b-" + b
+ ",t-" + t
+ "\ndonald-" + donald.getVal()
+ ",gerald-" + gerald.getVal()
+ ",robert-" + robert.getVal();
}
}
class Donald
{
public int D1 = 0;
public int O = 0;
public int N = 0;
public int A = 0;
public int L = 0;
public int D2 = 0;
public int getVal()
{
return D1 * 100000 + O * 10000 + N * 1000 + A * 100 + L * 10 + D2;
}
}
class Gerald
{
public int G = 0;
public int E = 0;
public int R = 0;
public int A = 0;
public int L = 0;
public int D = 0;
public int getVal()
{
return G * 100000 + E * 10000 + R * 1000 + A * 100 + L * 10 + D;
}
}
class Robert
{
public int R1 = 0;
public int O = 0;
public int B = 0;
public int E = 0;
public int R2 = 0;
public int T = 0;
public int getVal()
{
return R1 * 100000 + O * 10000 + B * 1000 + E * 100 + R2 * 10 + T;
}
}
}
c# donald gerald robert
最新推荐文章于 2024-11-07 08:51:26 发布