package
demo; import java.awt.List; import java.util.ArrayList; import java.util.Arrays; public class DemoClass { //定义成员变量 private int distance=0; private int[] list; private int init_number; DemoClass(int init_number, int[] list) { this.init_number = init_number; this.list = list; } public void fcfs() { for(int i : this.list) { if (i>this.init_number) { this.distance = this.distance+(i-this.init_number); this.init_number = i; }else { this.distance = this.distance+(this.init_number-i); this.init_number = i; } } System.out.print("先来先服务算法距离:"+this.distance); }public static void main(String[] args) { int[] list = {1,2,34,5}; DemoClass demo = new DemoClass(4,list); demo.sttw(); } }

相关文章:

  • 2021-08-08
  • 2021-06-04
  • 2022-12-23
  • 2021-06-05
  • 2021-07-13
  • 2021-10-14
  • 2022-12-23
  • 2021-04-05
猜你喜欢
  • 2022-12-23
  • 2021-12-18
  • 2021-05-28
  • 2021-04-17
  • 2021-11-08
  • 2021-06-17
  • 2021-09-13
相关资源
相似解决方案