Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.LinkedList;
- public class Put implements Comparable<Put>{
- class Cvor {
- int i;
- int j;
- int vr;
- public Cvor(int i, int j, int vr) {
- this.i = i;
- this.j = j;
- this.vr = vr;
- }
- public String toString() {
- return "[" + i + ", " + j + "]";
- }
- }
- LinkedList<Cvor> put = new LinkedList<Cvor>();
- int vrednost = 0;
- int maxCv = Integer.MIN_VALUE;
- int brojBlaga = 0;
- int uzastopnoBlago = 0;
- int uzastopnoBlagoMax = 0;
- boolean prethodniJeBlago = false;
- public void dodajCvor(int i, int j, int vr) {
- Cvor cv = new Cvor(i, j, vr);
- vrednost += vr;
- maxCv = Math.max(maxCv, vr);
- if(vr != 0) {
- brojBlaga++;
- }
- if(prethodniJeBlago && vr != 0) {
- uzastopnoBlago++;
- }
- else {
- if(vr != 0) {
- prethodniJeBlago = true;
- uzastopnoBlago = 1;
- }
- else {
- prethodniJeBlago = false;
- uzastopnoBlagoMax = Math.max(uzastopnoBlago, uzastopnoBlagoMax);
- }
- }
- put.add(cv);
- }
- public void izbrisiCvor() {
- put.removeLast();
- }
- public Put kopiraj() {
- Put novi = new Put();
- for(int i = 0; i < put.size(); i++) {
- Cvor tmp = put.get(i);
- novi.dodajCvor(tmp.i, tmp.j, tmp.vr);
- }
- return novi;
- }
- @Override
- public int compareTo(Put o) {
- return this.put.size() - o.put.size();
- }
- public void ispisiPut() {
- for(int i = 0; i < put.size(); i++) {
- System.out.println(put.get(i));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement