数字生成器并排显示

huangapple go评论65阅读模式
英文:

Number generator side by side

问题

import java.util.Random;

public class generator {

    public static void main(String []args){

        for(int i=0; i<10; i++ ){
            double random1 = 0.001 + Math.random() * (0.999 - 0.001);
            double random = 0.001 + Math.random() * (0.999 - 0.001);
            System.out.println(random1 + " ; " + random);
        }
    }
}
英文:

i have a simple question: i have this number generator that gives me 20 random numbers one below the other. But I want the last 10 numbers side by side to the top 10 numbers (and not among each other). And the numbers should be separated by a ; sign.
(something like that:
0,26842 ; 0,57317

0,26841 ; 0,68413

0,98147 ; 0,39874

.....

import java.util.Random;
public class generator{

    public static void main(String []args){

    for(int i=0; i&lt;10; i++ ){
      double random1 = 0.001 + Math.random() * (0.999 - 0.001);
      double random = 0.001 + Math.random() * (0.999 - 0.001);
      System.out.println(random1);
      System.out.println(random);
    }
}
}

</details>


# 答案1
**得分**: 1

Sure, here's the translated code and outputs:

```java
我希望我理解得很好。
public static void main(String[] args) {
    for(int i=0; i<10; i++ ){
      double random1 = 0.001 + Math.random() * (0.999 - 0.001);
      double random = 0.001 + Math.random() * (0.999 - 0.001);
      System.out.println(random1 + " ; " + random);
    }
}

输出结果:

0.7111252532926727 ; 0.9224161624866566
0.1045487636779416 ; 0.9453595177537817
0.3364050083322531 ; 0.7834084543275484
0.7598622603023293 ; 0.30580035501190783
0.7195115086875891 ; 0.8302980914411036
0.913950475634719 ; 0.2963283928642933
0.9945639974861409 ; 0.8683929505272162
0.06537064833948451 ; 0.0019845517993550433
0.7734798245619805 ; 0.7177276949135386
0.7722443930857127 ; 0.3079818592445528

如果这符合您的要求,请告诉我。

英文:

I hope I understood well.

public static void main(String[] args) {
    for(int i=0; i&lt;10; i++ ){
      double random1 = 0.001 + Math.random() * (0.999 - 0.001);
      double random = 0.001 + Math.random() * (0.999 - 0.001);
      System.out.println(random1 + &quot; ; &quot; + random);
    }
  }

outputs

0.7111252532926727 ; 0.9224161624866566
0.1045487636779416 ; 0.9453595177537817
0.3364050083322531 ; 0.7834084543275484
0.7598622603023293 ; 0.30580035501190783
0.7195115086875891 ; 0.8302980914411036
0.913950475634719 ; 0.2963283928642933
0.9945639974861409 ; 0.8683929505272162
0.06537064833948451 ; 0.0019845517993550433
0.7734798245619805 ; 0.7177276949135386
0.7722443930857127 ; 0.3079818592445528

Let me know if thats what you wanted

huangapple
  • 本文由 发表于 2020年10月9日 15:36:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/64275799.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定