[此贴子已经被作者于2007-4-17 16:25:20编辑过]
#include <stdio.h>
#include <conio.h>
int exchange(int);
int main(void)
{
int number;
clrscr();
printf("Please input a number:\n");
scanf("%d",&number);
/*For a int-type data in Turboc2.0,
it's value-area is -32768~32767*/
if(number<0) number=-number;
if(number>9999)
{
exchange(number/10000);
exchange((number%10000)/1000);
exchange((number%1000)/100);
exchange((number%100)/10);
exchange(number%10);
}
else if(number>999)
{
exchange(number/1000);
exchange((number%1000)/100);
exchange((number%100)/10);
exchange(number%10);
}
else if(number>99)
{
exchange(number/100);
exchange((number%100)/10);
exchange(number%10);
}
else if(number>9)
{
exchange(number/10);
exchange(number%10);
}
else
exchange(number);
getch();
}
int exchange(int number)
{
if(number==0)
printf("zero ");
else if(number==1)
printf("one ");
else if(number==2)
printf("two ");
else if(number==3)
printf("three ");
else if(number==4)
printf("four ");
else if(number==5)
printf("five ");
else if(number==6)
printf("six ");
else if(number==7)
printf("seven ");
else if(number==8)
printf("eight ");
else if(number==9)
printf("nine ");
}