Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- string words[] = {
- "Zero",
- "One",
- "Two",
- "Three",
- "Four",
- "Five",
- "Six",
- "Seven",
- "Eight",
- "Nine",
- "Ten",
- "Eleven",
- "Twelve",
- "Thirteen",
- "Fourteen",
- "Fifteen",
- "Sixteen",
- "Seventeen",
- "Eighteen",
- "Nineteen",
- "Twenty",
- "Twentyone",
- "Twentytwo",
- "Twentythree",
- "Twentyfour",
- "Twentyfive",
- "Twentysix",
- "Twentyseven",
- "Twentyeight",
- "Twentynine",
- "Thirty",
- "Thirtyone",
- "Thirtytwo",
- "Thirtythree",
- "Thirtyfour",
- "Thirtyfive",
- "Thirtysix",
- "Thirtyseven",
- "Thirtyeight",
- "Thirtynine",
- "Forty",
- "Fortyone",
- "Fortytwo",
- "Fortythree",
- "Fortyfour",
- "Fortyfive",
- "Fortysix",
- "Fortyseven",
- "Fortyeight",
- "Fortynine",
- "Fifty"
- };
- int maxNumber = sizeof(words) / sizeof(words[0]) - 1;
- string numToStr(int num)
- {
- return words[num];
- }
- int main()
- {
- int theNum = 0;
- do
- {
- cout << "Input a number between 0 and " << maxNumber << endl;
- cin >> theNum;
- } while (theNum < 0 || theNum > maxNumber);
- while (theNum != 4)
- {
- int temp = numToStr(theNum).length();
- cout << numToStr(theNum) << " is " << numToStr(temp) << endl;
- theNum = temp;
- };
- cout << "Four is the magic number" << endl;
- return 0;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement