Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to implement a two-dimensional Pole algorithm in java

Shulou Source: shulou.com Published: 2022-06-02 10:25:54 09月29日 Update

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.

Tags: Pole two-dimensional algorithm content skills knowledge conciseness brevity code that is articles more articles results industry information information channels channels management jackers + Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Apple Docker Linux Shulou Technology