求大神进来,问题是循环的
int r = 0;int count = 0;
while (count <= 1)
{
Random rd = new Random();
r = rd.Next(1000000, 9999999);
int q = r / 1000000; int w = r / 100000 % 10; int e = r / 10000 % 100; int t = r / 1000 % 1000; int y = r / 100 % 10000; int u = r / 10 % 100000; int o = r % 1000000;
int[] num = new int[7] { q, w, e, t, y, u, o };
for (int i = 0; i < 7; i++)
{
for (int j = i + 1; j < 7; j++)
{
if (num[i] == num[j])
{
break;
}
}
count += 1;
}
Console.WriteLine(r);
}
我要求得是一个不同数字的7位数,不知道错在哪?