冒泡排序

来源:互联网 发布:手机噪声测试软件 编辑:程序博客网 时间:2024/05/22 22:16
public class MaoPaoSort {public static void main(String[] args) {try {int mp[] = new int[args.length];for (int i = 0; i < args.length; i++) {mp[i] = Integer.parseInt(args[i]);}for (int i = 0; i < mp.length; i++) {for (int j = 0; j < mp.length; j++) {int temp;if (mp[i] < mp[j]) {temp = mp[j];mp[j] = mp[i];mp[i] = temp;}}}for (int i = 0; i < mp.length; i++) {System.out.print(mp[i] + " ");}System.out.print("\n");System.out.println("你的名字写在这里");System.out.println("你的班级写在这里");System.out.println("你的学号写在这里");} catch (Exception e) {System.out.println("没有传递参数或者参数类型不正确!请按照规则输入参数!程序退出...");}}}

原创粉丝点击