求助 程序强制结束
程序代码如下:#include"stdio.h"
#include"string.h"
#include"windows.h"
#include"ctype.h"
#include"stdlib.h"
int main()
{
int count = 0;
char number[5];
char enumber[9][6] = {"One","Two","Three","Four","Five","Six" ,"Seven","Eight","Nine"};
char bnumber[11][11] = {"Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen","Twenty"};
char cnumber[10][9] = {"Twenty","Thirty","Fouty","Tifty","Sixty","Seventy","Eighty","Ninty"};
int s;
char anwser;
while(1)
{
printf("请输入一个1000的正整数:\n");
scanf("%5s",number);
count = strlen(number);
if(number[0]=='0') //检查机制
{
printf("error");
return 1;
}
for(int i=0;count>i;i++) //检查机制
{
if(isdigit(number[i])==0)
{
printf("error!");
system("pause");
return 1;
}
}
if(count==1) //是否为一位
{
s = atoi(number);
printf("%s\n\n",enumber[s-1]);
}
if(count==2) //是否为两位
{
s = atoi(number);
if(s>=10&&s<=20)
printf("%s\n\n",s%10==0?(s==20?bnumber[10]:bnumber[0]):bnumber[s%10]);
else
printf("%s %s\n\n",cnumber[s/10-2],s%10==0?"":enumber[(s%10)-1]);
}
printf("输入N/n结束程序:");
scanf("%1c",anwser);
if(toupper(anwser)=='N')
break;
}
system("pause");
return 0;
}
编译运行这个程序后,会自己强制结束,说出现问题,停止工作。问题截图在附件中
[附件]问题截图[/附件]