数字生成器并排显示

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

Number generator side by side

问题

  1. import java.util.Random;
  2. public class generator {
  3. public static void main(String []args){
  4. for(int i=0; i<10; i++ ){
  5. double random1 = 0.001 + Math.random() * (0.999 - 0.001);
  6. double random = 0.001 + Math.random() * (0.999 - 0.001);
  7. System.out.println(random1 + " ; " + random);
  8. }
  9. }
  10. }
英文:

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

.....

  1. import java.util.Random;
  2. public class generator{
  3. public static void main(String []args){
  4. for(int i=0; i&lt;10; i++ ){
  5. double random1 = 0.001 + Math.random() * (0.999 - 0.001);
  6. double random = 0.001 + Math.random() * (0.999 - 0.001);
  7. System.out.println(random1);
  8. System.out.println(random);
  9. }
  10. }
  11. }
  12. </details>
  13. # 答案1
  14. **得分**: 1
  15. Sure, here's the translated code and outputs:
  16. ```java
  17. 我希望我理解得很好。
  1. public static void main(String[] args) {
  2. for(int i=0; i<10; i++ ){
  3. double random1 = 0.001 + Math.random() * (0.999 - 0.001);
  4. double random = 0.001 + Math.random() * (0.999 - 0.001);
  5. System.out.println(random1 + " ; " + random);
  6. }
  7. }

输出结果:

  1. 0.7111252532926727 ; 0.9224161624866566
  2. 0.1045487636779416 ; 0.9453595177537817
  3. 0.3364050083322531 ; 0.7834084543275484
  4. 0.7598622603023293 ; 0.30580035501190783
  5. 0.7195115086875891 ; 0.8302980914411036
  6. 0.913950475634719 ; 0.2963283928642933
  7. 0.9945639974861409 ; 0.8683929505272162
  8. 0.06537064833948451 ; 0.0019845517993550433
  9. 0.7734798245619805 ; 0.7177276949135386
  10. 0.7722443930857127 ; 0.3079818592445528

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

英文:

I hope I understood well.

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

outputs

  1. 0.7111252532926727 ; 0.9224161624866566
  2. 0.1045487636779416 ; 0.9453595177537817
  3. 0.3364050083322531 ; 0.7834084543275484
  4. 0.7598622603023293 ; 0.30580035501190783
  5. 0.7195115086875891 ; 0.8302980914411036
  6. 0.913950475634719 ; 0.2963283928642933
  7. 0.9945639974861409 ; 0.8683929505272162
  8. 0.06537064833948451 ; 0.0019845517993550433
  9. 0.7734798245619805 ; 0.7177276949135386
  10. 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:

确定