01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
package algs31;
import stdlib.*;
import algs35.ST;

public class XCount {

  public static void main(String[] args)
  {
    ST<String, Integer> st = new ST<>();
    for (int i = 0; !StdIn.isEmpty(); i++)
    {
      String key = StdIn.readString();
      st.put(key, i);
    }
    for (String s : st.keys())
      StdOut.println(s + " " + st.get(s));
  }
}