math.random()编辑
目录
1flash的代码编辑
2java的代码编辑
|
1
|
Math.random()*(n-m+
1
)+m;
|
|
1
2
3
4
5
6
7
8
9
10
11
|
public
static
void
main(String[]args){
String result=
""
;
for
(inti=
0
;i<
6
;i++){
//生成97-122的int型的整型
int
intValue=(
int
)(Math.random()*
26
+
97
);
//将intValue强制转化成char类型后接到resul后面
result=result+(
char
)intValue;
}
//输出字符串
System.out.println(result);
}
|
3Math.random();使用方法编辑
|
1
2
3
4
5
6
7
8
9
10
|
classIsUpper{
publicstaticvoidmain(String[]args){
charch;
ch=(
char
)(Math.random()*
128
);
if
(ch>=
'A'
&&ch<=
'Z'
)
System.out.println(
"Yes!"
);
else
System.out.println(
"No!"
);
}
}
|
|
1
|
document.write(Math.random());
|
|
1
|
document.write(Math.random()*(
20
-
10
)+
10
);
|
|
1
|
document.write(Math.random()*(n-m)+m);
|
-
参考资料
-
-
449



被折叠的 条评论
为什么被折叠?



