Topic: 求助:(如何隨機產生10个介於50~100間6的倍數)

  Print this page

1.求助:(如何隨機產生10个介於50~100間6的倍數) Copy to clipboard
Posted by: kid01
Posted on: 2005-07-28 11:51

请使用准确的文字描述作为标题
Your next post without a proper Subject will be removed.

DO YOUR HOMEWORK,
TRY TO DO WHAT YOU CAN DO FIRST

Original subject :
求助:望哪位大虾前来救急~


如何写一个會隨機產生10个介於50~100間6的倍數的程式啊~

2.Re:求助:望哪位大虾前来救急~ [Re: kid01] Copy to clipboard
Posted by: ranchgirl
Posted on: 2005-07-28 12:09

Do your homework!

3.Re:求助:望哪位大虾前来救急~ [Re: kid01] Copy to clipboard
Posted by: kid01
Posted on: 2005-07-28 14:49

- -做得出就不会来求救了撒 speak Chinese please~

4.Re:求助:望哪位大虾前来救急~ [Re: kid01] Copy to clipboard
Posted by: lvmingtao
Posted on: 2005-07-28 15:29

如何写一个會隨機產生10个介於50~100間6的倍數的程式啊~
public class app{
public start void mian (String arg[]) {
int number, i=1,dex;
double j;
while(i<=10){
j=Math.ramdom();
if (j>=0.5) {
if ((int)(100*j)%6=0){
system.out.println("number="+number=((int)(100*6)));
i++;}
else
continue;}
}
不知道对不对~~~~有结果别忘了回复

5.Re:求助:望哪位大虾前来救急~ [Re: kid01] Copy to clipboard
Posted by: lvmingtao
Posted on: 2005-07-28 15:43

如何写一个會隨機產生10个介於50~100間6的倍數的程式啊~
100*(1-0.5*(MATH.RAMDOM()))
  对不对 给个回复~~~我的QQ46214405
   你要是什么好的JAVA题 ??
  告诉我好吗 ?? 谢谢
   

6.Re:求助:(如何隨機產生10个介於50~100間6的倍數) [Re: kid01] Copy to clipboard
Posted by: xiemingyou
Posted on: 2005-08-01 13:54

import java.util.*;

public class RandomTest {

  public static void main(String[] args){
    
    Random rand = new Random();
    int flag = 0;
    
    while(flag != 10){
    
      int i = rand.nextInt(50)+50;
      if(i%6 == 0){
        
        flag++;
        System.out.println( i );
    
      }
    }
  }
}
希望大家提意见!

7.Re:求助:(如何隨機產生10个介於50~100間6的倍數) [Re: kid01] Copy to clipboard
Posted by: ljy0000
Posted on: 2005-08-01 14:21


import java.util.*;

public class P1 {

public static void main(String[] args) {
int num[]={54,60,66,72,78,84,90,96};
Random random=new Random();
for(int i=0;i<10;i++){
System.out.println(num[random.nextInt(num.length)]);
  }
}
}

8.Re:求助:(如何隨機產生10个介於50~100間6的倍數) [Re: ljy0000] Copy to clipboard
Posted by: scottlai
Posted on: 2005-08-02 23:03

牛啊Big Smile

ljy0000 wrote:

import java.util.*;

public class P1 {

public static void main(String[] args) {
int num[]={54,60,66,72,78,84,90,96};
Random random=new Random();
for(int i=0;i<10;i++){
System.out.println(num[random.nextInt(num.length)]);
  }
}
}


9.Re:求助:(如何隨機產生10个介於50~100間6的倍數) [Re: kid01] Copy to clipboard
Posted by: 烂泥
Posted on: 2005-08-02 23:10

这个结果肯定对! Scott 都说牛了Wink

10.Re:求助:(如何隨機產生10个介於50~100間6的倍數) [Re: kid01] Copy to clipboard
Posted by: seayc
Posted on: 2005-08-03 09:58

等会,,,,,50-100之间6的倍数只有8个亚
54
60
66
72
78
84
90
96

11.Re:求助:(如何隨機產生10个介於50~100間6的倍數) [Re: seayc] Copy to clipboard
Posted by: 鹅卵石
Posted on: 2005-08-03 10:09

出题人更牛

12.Re:求助:(如何隨機產生10个介於50~100間6的倍數) [Re: seayc] Copy to clipboard
Posted by: seman
Posted on: 2005-08-03 10:13

seayc wrote:
等会,,,,,50-100之间6的倍数只有8个亚
54
60
66
72
78
84
90
96


可以产生重复的数字的吧


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923