我想生成一个不应大于变量'max'的随机数,并满足以下条件:
int fi= 17;
int max=96;
int i=1;
int rez=0;
while(i<max)
{
if((i*max)%fi==1) rez=i;
i++;
}
System.out.println(rez);
结果总是0.什么错?
答案 0 :(得分:1)
SELECT vwemployee.directorateName AS dN, COUNT( vwemployeeCourse.employeeId ) AS t1, t2
FROM vwemployee
JOIN vwemployeeCourse ON vwemployee.directorateName = vwemployeeCourse.directorateName
LEFT JOIN (
SELECT vwemployee.directorateName AS ecdN, COUNT( vwemployee.directorateName ) AS t2
FROM vwemployee
JOIN employeeCourse ON vwemployee.Id = employeeCourse.employeeId
GROUP BY vwemployee.directorateName
) AS EmployeeCount
ON dN = ecdN
GROUP BY vwemployee.directorateName
输出: 我: - 14 我: - 31 我: - 48 我: - 65 我: - 82
答案 1 :(得分:0)
我在你编写的时候使用max而不是rand启动你的程序修改并在循环中添加一些printf。这是代码:
#include <stdio.h>
void main()
{
int fi= 17;
int max=96;
int i=0;
int rez=0;
while(i<max)
{
printf("\n%i", (i*max)%fi);
if((i*max)%fi==1)
{
rez=i;
printf(" -> %i", rez);
}
i++;
}
printf("\n");
printf("\nFinal result: %i", rez);
printf("\n");
}
这是输出:
0
11
5
16
10
4
15
9
3
14
8
2
13
7
1 -> 14
12
6
0
11
5
16
10
4
15
9
3
14
8
2
13
7
1 -> 31
12
6
0
11
5
16
10
4
15
9
3
14
8
2
13
7
1 -> 48
12
6
0
11
5
16
10
4
15
9
3
14
8
2
13
7
1 -> 65
12
6
0
11
5
16
10
4
15
9
3
14
8
2
13
7
1 -> 82
12
6
0
11
5
16
10
4
15
9
3
14
8
Final result: 82
如你所说,我并不总是0。你从哪里得到0?