A
ARMAS
could you give me the rpogram in changing digits into words??
Ex: input:1435 outputne thousand four hundred thirty five......
Ex: input:1435 outputne thousand four hundred thirty five......
ARMAS said:could you give me the rpogram in changing digits into words??
Ex: input:1435 outputne thousand four hundred thirty five......
ARMAS said:could you give me the rpogram in changing digits into words??
Ex: input:1435 outputne thousand four hundred thirty five......
If you show us your effort so far, we'll be glad to help. But we would
never harm you in such a way as to do your homework for you, therefore
robbing you of a quality education that is costing you so dearly.
ARMAS said:could you give me the rpogram in changing digits into words??
Ex: input:1435 outputne thousand four hundred thirty five......Here's one I wrote a number of years ago.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *ordinal (char buf[1024], unsigned value);
int
main (int argc, char *argv[])
{
char buf[1024];
if (argc != 2)
{
printf ("usage: ordinal <number>\n");
return EXIT_FAILURE;
}
ordinal (buf, atoi (argv[1]));
puts (buf);
return EXIT_SUCCESS;
}char *
ordinal (char buf[1024], unsigned value)
{
static const char *const powers[]
= {"man", "oku"};
static const char *const values[][9] =
{
{"sen", 0, "sanzen", 0, 0, 0, 0, "hassen", 0},
{"hyaku", 0, "sanbyaku", 0, 0, "roppyaku", 0, "happyaku", 0},
{"juu", 0, 0, 0, 0, 0, 0, 0, 0},
{"ichi", "ni", "san", "yon", "go", "roku", "nana", "hachi", "kyuu"},
};
static const char *const *const ones = values[3];
char *cp = buf;
if (value == 0)
{
strcpy (buf, "rei");
return buf;
}
{
int part_stack[4];
int *part_ptr = part_stack;
for (; value; value /= 10000)
*part_ptr++ = value % 10000;
while (part_ptr > part_stack)
{
int index[4];
int p, i;
p = *--part_ptr;
for (i = 3; i >= 0; i--)
{
index = p % 10;
p /= 10;
}
for (i = 0; i < 4; i++)
{
int c = index;
if (c != 0)
{
if (values[c - 1] == 0)
cp += sprintf (cp, "%s%s ", ones[c - 1], values[0]);
else
cp += sprintf (cp, "%s ", values[c - 1]);
}
}
if (*part_ptr && part_ptr > part_stack)
cp += sprintf (cp, "%s ", powers[part_ptr - part_stack - 1]);
}
}
cp[-1] = 0;
return buf;
}/*
Local variables:
compile-command: "gcc -W -Wall -ansi -pedantic ordinal-jp.c -o ordinal-jp"
End:
*/
decorative; they indicate that you're quoting something that someone
else wrote.
"you better work on it too"? I don't think so. If you ask for our
help, we might give it to you; if you demand it, you're on your own.
decorative; they indicate that you're quoting something that someone
else wrote."you better work on it too"? I don't think so. If you ask for our
help, we might give it to you; if you demand it, you're on your own.
two words for you though: "suck it"
ARMAS said:[...]"you better work on it too"? I don't think so. If you ask for our
help, we might give it to you; if you demand it, you're on your own.
I'm just a begginer... I'm sorry if i don't know that much... I've got
two words for you though: "suck it"
could you give me the rpogram in changing digits into words??
Ex: input:1435 outputne thousand four hundred thirty five......
ARMAS said:could you give me the rpogram in changing digits into words??
Ex: input:1435 outputne thousand four hundred thirty five......
"\164\157\40\160\162\157\143\145\163\163\40\156\165\155\142\145\162"21)??<puts("\105\162\162\157\162\41\40\40\125\156\141\142\154\145\40"
user923005 said:{"ichi", "ni", "san", "she", ...
Unless there is a dialect I do not know about.
ARMAS said:are you japanese, chinese or whatever?????
Japenese when I was an undergrad. If you want more information,
putting "shi yon" into Google is informative.
--
int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.\
\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p\
);}return 0;}
[snip]/* I say we give this poor kid a hand: */
I'm just a begginer... I'm sorry if i don't know that much... I've got
two words for you though: "suck it"
{
switch(i)
{
case 0: return "zero";
case 1: return "one";
case 2: return "two";
case 1435: return "one thousand four hundred thirty five";
default: return "unknown number";
}
}
Extend as needed.
Replace English words with Roman numerals for your other homework
problem. ie:
case 1: return "I";
case 2: return "II";
case 1435: return "MCDXXXV";
--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody |www.hvcomputer.com| #include |
| kenbrody/at\spamcop.net |www.fptech.com | <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:[email protected]>
I'm just a begginer... I'm sorry if i don't know that much... I've got
two words for you though: "suck it"
Probably not. Methinks this is C code for "suck it".hey , what i mean is, user gets to input any number, not just the
example.... are you making fun of me???
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.