java中有一个排好序的数组,【java经典算法】有一个已经排好序的数组。现输入一个数,要求按原来的规律将它插入数组中...

《【java经典算法】有一个已经排好序的数组。现输入一个数,要求按原来的规律将它插入数组中》由会员分享,可在线阅读,更多相关《【java经典算法】有一个已经排好序的数组。现输入一个数,要求按原来的规律将它插入数组中(4页珍藏版)》请在技术文库上搜索。

1、/Java 里弹对话框 import javax.swing.JOptionPane; import java.util.Arrays; import java.util.Random; public class ArraySortMine public static void main(String args) int temp = 0; int myarr = new int12; Random r = new Random(); for (int i = 1; i myarrk) temp = myarri; myarri = myarrk; myarrk = temp; System.。

2、out.println(); System.out.println(“The sort data:“); for (int k = 1; k = 10; k+) System.out.print(myarrk + “,“); / here will a Diamonds / 我想让对话框出现提示三次(这时是 alert) ,,之前的提示应该有两个按钮,Yes 和 No 用户体验思想,不多说 / http:/blog.sina.com.cn/robertlizhiqiang Object possibleValues = “insert data by mysesf “, “Please Fil。

3、l data for me! “ ; Object selectedValue = JOptionPane.showInputDialog(null, “Choose one “, “Input “, JOptionPane.INFORMATION_MESSAGE, null, possibleValues, possibleValues0); if (selectedValue = “insert data by mysesf “) String inputValue = JOptionPane .showInputDialog(“Please input your access data(。

4、Only 3 times)! “); / first time input data if (inputValue != null catch (NumberFormatException e) / System.out.println(e.getMessage(); /* * JOptionPane.showMessageDialog(null, “your data: “ + * e.getMessage() + * “is not Number!System will select one for you!“, * “alert “, JOptionPane.ERROR_MESSAGE)。

5、; myarr11 = * r.nextInt(100); */ / second time to input data Object options = “让我再输一次吧“, “请系统自动为我输入“ ; boolean optionYes = false; optionYes = JOptionPane.showOptionDialog(null, “你妹啊,你输的“ + e.getMessage() + “就不是数字!“, “你故意的搞我程序的吧“, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options。

6、, options0) = JOptionPane.YES_OPTION; if (optionYes) / 继续代码 String inputValue2 = JOptionPane .showInputDialog(“Please input your access data(Now Last times)! “); if (inputValue2 != null catch (NumberFormatException e1) / The last time to permit to input data! Object optionsThird = “给我最后次机会吧“, “系统给 我。

7、输吧“ ; boolean optionYesThird = false; optionYesThird = JOptionPane.showOptionDialog( null, “我晕,你妹啊,2 次了n 你输的“ + e1.getMessage() + “就不是数字!“, “你故意的搞我程序的吧“, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, optionsThird, optionsThird0) = JOptionPane.YES_OPTION; if (optionYesThird) / 继续【原文:。

8、 http:/blog.sina.com.cn/s/blog_6829be5c0100twxz.html】 String inputValue3 = JOptionPane .showInputDialog(“Please input your access data(Now 2 times)! “); if (inputValue3 != null catch (NumberFormatException e3) / 警告之系统输入 JOptionPane .showMessageDialog( null, “damn!ndamn!ndamn!nyour data: “ + e3 .getM。

9、essage() + “is not Number 3times!nSystem will select one for you!“, “alert “, JOptionPane.ERROR_MESSAGE); myarr11 = r.nextInt(100); else JOptionPane .showMessageDialog( null, “you have not send data!System will select one for you! “, “alert “, JOptionPane.ERROR_MESSAGE); myarr11 = r.nextInt(100); el。

10、se JOptionPane.showMessageDialog(null, “System will select one for you! “, “alert “, JOptionPane.ERROR_MESSAGE); myarr11 = r.nextInt(100); else JOptionPane .showMessageDialog( null, “you have not send data!System will select one for you! “, “alert “, JOptionPane.ERROR_MESSAGE); myarr11 = r.nextInt(100); else myarr11 = r.nextInt(100); System.out.println(); System.out.println(“The insert data:“); System.out.println(myarr11); Arrays.sort(myarr);/ 因为数组里面没有空数字了,所以用这个方法不会有问题了 System.out.println(“The last data:“); for (int k = 1; k = 11; k+) System.out.print(myarrk + “,“); 。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值