[求助]windous为什么不让运行
输入正整数N(N<1000),产生对应的英文字符串并输出。例如1 ONE
2、TWO
3、THREE
……
11 ELEVEN
135 ONE HANDRED TRIRTY FIVE
昨天问了这题的算法
今天试着写了,但程序无法运行,请版主指教
/*HaPpY随心*/
#include <stdio.h>
#include <string.h>
int main()
{
int i,n,k,m;
char st[9];
char *day[9]={"ONE","TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT",
"NINE"};
char *teen[9]={"ELEVEN","TWELVE","THITRTEEN","FOURTEEN","FIFTEEN","SIXTEEN",
"SEVENTEEN","EIGHTEEN","NINETEEN"};
char *tenth[8]={"TWENTY","THIRTY","FOURTY","FIFTY","SIXTY","SEVENTY",
"EIGHTY","NINETY"};
char *a[2]={"TEN","HUNDRED"};
printf("请输入1000以内正整数:\n");
scanf("%s",st);
k=strlen(st);
for(i=0;i<k;i++)
{
if(st[i]>'9'||st[i]<'1') return 0;
}
switch(k)
{
case 1:
n=int(st[0]-'0');
printf("%s\n",*day[n-1]);
break;
case 2:
if(st[1]=='1')
{
if(st[0]=='0') printf("%s\n",*a[0]);
else
{
n=int (st[0]-'0');
printf("%s\n",*teen[n-1]);
}
}
else
{
i=int(st[1]-'0');
n=int(st[0]-'0');
}
printf("%s-%s",*tenth[i-2],*day[n-1]);
break;
case 3:
m=int(st[2]-'0');
if(st[1]=='1')
{
if(st[0]=='0') printf("%s %s %s\n",*day[m-1],*a[1],*a[0]);
else
{
n=int(st[0]-'0');
printf("%s %s %s\n",*day[m-1],*a[1],*teen[n-1]);
}
}
else
{
i=int(st[1]-'0');
n=int(st[0]-'0');
}
printf("%s %s %s-%s",*day[m-1],*a[1],*tenth[i-2],*day[n-1]);
break;
default:
printf("error!");
return 0;
}
return 0;
}