public class A {
public static void main(String[] args) {
Random random = new Random();
int[]a = new int [25];
for (int i =0;i <= 24 ;i++ ){
a[i] = random.nextInt(100)+1;
}
for (int i =0;i < 25 ;i++ ){
if (i == 0) {
System.out.print(a[0]);
continue;
}
if (a[i-1] == a[i]) {
System.out.print("="+a[i]);
continue;
}
if (a[i-1] > a[i]) {
System.out.print(">"+a[i]);
continue;
}
if (a[i-1] < a[i]) {
System.out.print("<"+a[i]);
continue;
}
}
}
}
此博客展示了一段Java代码,创建了一个长度为25的整型数组,数组元素为1 - 100的随机整数。接着对数组元素进行比较,根据相邻元素的大小关系,以特定符号(=、>、<)连接元素并输出。
748

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



