-
Title Description:
-
Read in two positive integers a and B less than 100, calculate a+b.
It is important to note that each digit of A and b is given by the corresponding English word.
-
Input:
The
-
test input contains several test cases, one row for each test case, the format "A + B =", and two adjacent strings with a space interval. When both A and B are at the end of 0 o'clock input, the corresponding result is not output.
-
Output:
-
Output 1 rows for each test case, which is the value of a+b.
-
Sample input:
-
One + =three four + five six =zero seven + eight nine =zero + zero =
-
Sample output:
-
39096
1 Importjava.util.Hashtable;2 ImportJava.util.Scanner;3 4 Public classmain{5 Public Static voidMain (String[]args) {6Scanner in=NewScanner (system.in);7Hashtable<string,integer> ht=NewHashtable ();8 inithashtable (HT);9 while(In.hasnext ()) {TenString input=in.nextline (); OneString[] T=input.split (""); A intlen=t.length; - intCout=0; -string[]num=NewString[2]; theNum[0]= ""; -Num[1]= "";//Be sure to initialize to an empty string, otherwise add a number, such as 1, will become null1; - for(inti=0;i<len;i++){ - if(T[i].equals ("+")){ +cout++; - Continue; + } A Else if(T[i].equals ("=")){ at Continue; - } - intA=Ht.get (T[i]); -num[cout]=num[cout]+A; - } - intX=integer.parseint (num[0]); in intY=integer.parseint (num[1]); - if(x==0&&y==0){ to Break; + } -System.out.println (x+y); the } * } $ Panax Notoginseng Public Static voidInitHashTable (hashtable<string,integer>HT) { -Ht.put ("zero", 0); theHt.put ("One", 1); +Ht.put ("Both", 2); AHt.put ("Three", 3); theHt.put ("Four", 4); +Ht.put ("Five", 5); -Ht.put ("Six", 6); $Ht.put ("Seven", 7); $Ht.put ("Eight", 8); -Ht.put ("Nine", 9); -Ht.put ("Tene", 10); the } - }Wuyi /************************************************************** the problem:1010 - user:0000h Wu Language:java - result:accepted About time:80 Ms $ memory:15548 KB - ****************************************************************/
Topic 1010:a + B