当前位置 : 主页 > 编程语言 > java >

算法7树的问题

来源:互联网 收集:自由互联 发布时间:2021-06-28
合并 import java.util.Scanner;public class Test3 { public static void main(String[] args){ Scanner scan = new Scanner(System.in); int l = scan.nextInt(); //长度 int m = scan.nextInt(); // int[] a = new int[m]; int[] b = new int[m]; int
合并
import java.util.Scanner;

public class Test3 {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int l = scan.nextInt();      //长度
        int m = scan.nextInt();     //
        int[] a = new int[m];
        int[] b = new int[m];
        int i,j;
        for (i=0; i
 
  i; j--){
                    if(a[i]>a[i+1]){
                        temp = a[i];
                        a[i] = a[i+1];
                        a[i+1] = temp;
                        temp = b[i];
                        b[i] = b[i+1];
                        b[i+1] = temp;
                    }
                }
            }
        }catch(Exception e){

        }
        int max = b[0]-a[0]+1;
        for(i=1; i
  
   b[i-1]){ max = max+b[i]-a[i]+1; }else{ if(b[i]
  
 
网友评论