Output 99 multiplication table
Import Java.util.hashmap;import java.util.iterator;import Java.util.map;import Java.util.map.entry;import Java.util.set;public class Multiplicationtable {public static void main (string[] args) {//defines a string cache for storing product results StringBuffer SB = new StringBuffer ();//output multiplication table for (int i=1; i<=9; i++) {for (int j=1; j<=i; J + +) { To make alignment adjustments, start with the second column, and if the result length is single digit, fill in the blanks if (J ==2 && string.valueof (i*j). Length () = = 1) { System.out.print (j + "*" + i + "=" + I*j + ""); Put the accumulation in SB sb.append (I*J); } else {System.out.print (j + "*" + i + "=" + I*j + "); Sb.append (I*J); }}//end of line, line wrap Operation System.out.println (); }//define map, hold characters and the number of occurrences map<character, integer> map = new Hashmap<character, Integer > (); STring str = sb.tostring (); Traverses str, storing characters and their occurrences in map for (int i=0; i<str.length (); i++) {Character num = Str.charat (i); if (null! = Map.get (num)) {map.put (num, map.get (num) + 1); } else {map.put (num, 1); }}//Get Entry result set and traverse output Set<entry<character, integer>> entryset = Map.entryset (); Iterator<entry<character, integer>> it = Entryset.iterator (); while (It.hasnext ()) {entry<character, integer> Entry = It.next (); System.out.println (Entry.getkey () + "" + Entry.getvalue ()); }}}
Output 9 by 9 multiplication tables and achieve 0-9 occurrences of each number and print out