发布网友 发布时间:2023-10-23 04:08
共4个回答
热心网友 时间:2024-11-24 15:28
人家都说初学了!你们看看你们发的那叫什么答vv案!
既然你是初学,我就把所有代码都发上来!
另外我还有初学者的实例代码。多的不得了!想要的话OICQ⒉⒏⒉⒈⒋⒊⒏⒐⒌
谁举报我不得好SI!
简单易懂!
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class TestBj {
public static void main(String[] args) throws IOException {
int[] bj = new int[4];
int i;
int k;
int t;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
for (i = 0; i < bj.length; i++) {
System.out.print("请输入你要比较的第" + (i + 1) + "个数字:");
bj[i] = Integer.parseInt(br.readLine());
}
System.out.print("比较前您输入的4个比较数字是:");
for (i = 0; i < bj.length; i++) {
System.out.print(bj[i] + " ");
}
System.out.println();
for (i = 0; i < bj.length; i++) {
for (k = 0; k < bj.length - 1; k++) {
if (bj[k] < bj[k + 1]) {
t = bj[k];
bj[k] = bj[k + 1];
bj[k + 1] = t;
}
}
}
System.out.print("比较后的结果是:");
for (i = 0; i < bj.length; i++) {
System.out.print(bj[i] + " ");
}
}
}
热心网友 时间:2024-11-24 15:28
int a[]={3,4,5,12};热心网友 时间:2024-11-24 15:29
int a[]={3,4,5,12};热心网友 时间:2024-11-24 15:30
int a=1;