标签:cti min() adl import for col div IV sem
//优先队列
import edu.princeton.cs.algs4.*; public class TopM { public static void main(String[] args) { int M = Integer.parseInt(args[0]); MinPQ<Transaction> pq = new MinPQ<Transaction>(M+1); while(StdIn.hasNextLine()) { pq.insert(new Transaction(StdIn.readLine())); if(pq.size() > M) pq.delMin(); } Stack<Transaction> stack = new Stack<Transaction>(); while(!pq.isEmpty()) stack.push(pq.delMin()); for(Transaction t : stack) StdOut.println(t); } }
标签:cti min() adl import for col div IV sem
原文地址:https://www.cnblogs.com/w-j-c/p/9130991.html