Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; class SLLNode { protected int id; protected int plata; protected SLLNode succ; public SLLNode(int id,int plata, SLLNode succ) { this.id = id; this.plata=plata; this.succ = succ; } } class SLL { private SLLNode first; public SLL() { // Construct an empty SLL this.first = null; } public void deleteList() { first = null; } public int length() { int ret; if (first != null) { SLLNode tmp = first; ret = 1; while (tmp.succ != null) { tmp = tmp.succ; ret++; } return ret; } else return 0; } public void insertFirst(int id, int plata) { SLLNode ins = new SLLNode(id,plata, first); first = ins; } public void insertLast(int id,int plata) { if (first != null) { SLLNode tmp = first; while (tmp.succ != null) tmp = tmp.succ; SLLNode ins = new SLLNode(id, plata, null); tmp.succ = ins; } else { insertFirst(id,plata); } } public SLLNode getFirst() { return first; } public SLL brisi_pomali_od(int iznos) { SLL nova_lista = new SLL(); SLLNode head = getFirst(); while(head != null) { if(head.plata > iznos) { nova_lista.insertLast(head.id, head.plata); } head = head.succ; } return nova_lista; } public SLL sortiraj_opagacki() { SLL nova_lista = new SLL(); SLLNode head = getFirst(); if(head == null) { System.out.println("nema"); return new SLL(); } while(head != null) { SLLNode sosed = head.succ; while(sosed != null) { if(head.id < sosed.id) { int tmp_id = head.id; int tmp_plata = head.plata; head.id = sosed.id; head.plata = sosed.plata; sosed.id = tmp_id; sosed.plata = tmp_plata; } sosed = sosed.succ; } nova_lista.insertLast(head.id, head.plata); head = head.succ; } return nova_lista; } public void pecati (SLL lista) { SLLNode p=lista.first; while(p!=null) { System.out.println(p.id+","+p.plata); p=p.succ; } } } public class SLLKompanija { public static void main(String[] args) throws IOException { SLL lista1 = new SLL(); BufferedReader stdin = new BufferedReader(new InputStreamReader( System.in)); String s = stdin.readLine(); int N = Integer.parseInt(s); for (int i = 0; i < N; i++) { s=stdin.readLine(); String s1=stdin.readLine(); lista1.insertLast(Integer.parseInt(s),Integer.parseInt(s1)); } s = stdin.readLine(); lista1=lista1.brisi_pomali_od(Integer.parseInt(s)); if(lista1!=null) { lista1=lista1.sortiraj_opagacki(); lista1.pecati(lista1); } } }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)