fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. char* One2Nineteen[] = {"", "One", "Two", "Three", "Four", "Five", "Six",
  5. "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen",
  6. "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"};
  7.  
  8. char* Twenty2Ninety[] = {"", "", "Twenty", "Thirty", "Forty", "Fifty",
  9. "Sixty", "Seventy", "Eighty", "Ninety"};
  10.  
  11. char* One_Nineteen(int x) {
  12. return One2Nineteen[x < 20 ? x : x % 10];
  13. }
  14.  
  15. char* Twenty_Ninety(int x) {
  16. char* cp = (char*)malloc(sizeof(char) * 32);
  17. sprintf(cp, "%s%s", Twenty2Ninety[x / 10], (x % 10 == 0 || x < 20) ? "" : "-");
  18. return cp;
  19. }
  20.  
  21.  
  22. int main(void) {
  23. char a[3];
  24. scanf("%2s%*[^\n]", a);
  25. int x = strtol(a, NULL, 10);
  26. printf("%s%s\n", Twenty_Ninety(x), One_Nineteen(x));
  27. return EXIT_SUCCESS;
  28. }
  29.  
Success #stdin #stdout 0.01s 5460KB
stdin
Standard input is empty
stdout