英文:
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<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<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);
}
}
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论