do-while语句求1~1000之间满足“用3除余2;用5除余3;用7 除余2”的数,且只打印5个数

2024-11-24 01:23:49
推荐回答(2个)
回答1:

int num = 1;
int count = 0;
do{
if(num % 3 == 2 && num %5 == 3 && num % 7 == 2)
{
System.out.println(num);
count++;
}
num++;
}while(num < 1000 && count < 5);

回答2:

do
do
if i mod 3 =3
if i mod 5 =3
if i mod 7 =2
pribt i
t=t+1
next
next
next
while i=1 to 1000 i++
while t<=5