# Include <iostream> # include <stack> # include <string. h> char * g_wordtable [10] = {"zero", "one", "two", "three", "four", "five", "Six ", "Seven", "eight", "Nine "};
Int main () {// The Char input [1000] that stores user input data; // when user input data is not stopped while (scanf ("% s ", & input )! = EOF) {int sum = 0; // obtain the length of user input data, using string. h int Len = strlen (input); // convert each character into an ascii code. The ASCII code of a number character is equal to the number itself, and the sum is for (INT I = 0; I <Len; ++ I) sum + = (input [I]-'0'); // defines a stack STD: Stack <int> S; // split the bit. The bit is first put into the stack, and then there are ten hundred do {int temp = sum % 10; S. push (temp); sum/= 10;} while (sum! = 0); // output, empty determines whether the stack is empty while (! S. empty () {// obtain the data int T = s on the top of the stack. top (); // size returns the current stack length (that is, the number of internal data) // if the size of the stack is greater than 1 if (INT) s. size ()> 1) printf ("% s", g_wordtable [T]); else printf ("% s \ n", g_wordtable [T]); // pop pops up the element S at the top of the stack. pop () ;}} return 0 ;}
Conclusion: 1. Better understanding of pointer array definition strings and two-dimensional array definition strings
2. Measure the test taker's knowledge about how to split items.
3. Master the stack method