Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement a two-dimensional Pole algorithm in java

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article shows you how to implement a two-dimensional pole algorithm in java, concise and easy to understand, absolutely can make your eyes shine, through the detailed introduction of this article I hope you can gain something.

People who use it will understand this description, not much to say directly on the code

public class maxtest { public static void main(String[] args) { //################### String[] ewjd = {"2,4","5,3","15,7","3,10","10,6","6,8","8,2","13,5","13,7"}; List listewjd = new ArrayList(); String newewjd; for (int j = 0; j

< ewjd.length-1; j++) { for (int i = 0; i < ewjd.length; i++) { if(ewjd.length-1 == i){ break; }else{ String[] split = ewjd[i].split(","); String[] split2 = ewjd[i+1].split(","); if(Integer.parseInt(split[0]) >

Integer.parseInt(split2[0])){ newewjd = ewjd[i]; ewjd[i] = ewjd[i+1]; ewjd[i+1] = newewjd; } } } } for (int i = 0; i

< ewjd.length; i++) { listewjd.add(ewjd[i]); } System.out.println(jddg(listewjd,1)); //###################二维极点start###################// } //二维极点递归public static List jddg (List listewjd,int start){ if (start == 1) { start = 0 ; for (int i = listewjd.size()-1; i >

= 0; i--) { if(0 == i){ break; }else{ String[] split = listewjd.get(i).toString().split(","); String[] split2 = listewjd.get(i-1).toString().split(","); if(Integer.parseInt(split[1]) >= Integer.parseInt(split2[1])){ listewjd.remove(i-1); start = 1; } } } jddg(listewjd,start); } return listewjd; }}

The results were as follows:

[3,10, 6,8, 15,7]

The above content is how to implement a two-dimensional pole algorithm in java. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserves, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report