2020-12-11
作者:互联网
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
long fun()
{
int i;
long num;
for(i=1;i>0;i++)
{srand((unsigned)time(NULL));
num=rand()+10000; //生成随机数
if(num<=2147483647) break; //判断随机数是否超出取值范围
}
printf("The value is %d\n",num);
return num;
}
void translate(long num)
{
int *p,i,j,k,temp;
long num0=num,num1=num0;
j=0;
for(i=0;i>=0;i++)
{
j=j+1;
if(num0/10==0) break;
num0=num0/10;
} //得到随机数宽度
p=(int *)malloc(j * sizeof(int));//动态生成长度与随机数宽度相同的数组
for(i=j-1;i>0||i==0;i--)
{p[i]=num1%10;
if(num1/10==0) break;
num1=num1/10;} //将随机数的每个数字赋给数组
for(i=0;i<j;i++)
{
if(p[i]==0) printf("zero ");
if(p[i]==1) printf("one ");
if(p[i]==2) printf("two ");
if(p[i]==3) printf("three ");
if(p[i]==4) printf("four ");
if(p[i]==5) printf("five ");
if(p[i]==6) printf("six ");
if(p[i]==7) printf("seven ");
if(p[i]==8) printf("eight ");
if(p[i]==9) printf("nine ");
} //输出数字的英文
}
void main()
{
translate(fun());
printf("\n");
}
标签:11,10,12,num0,num1,int,num,2020,printf 来源: https://blog.csdn.net/weixin_52799893/article/details/111054100