帮忙看下彩票中奖程序
题目要求:1.根据卡号抽奖,卡号必须是4位数。如果不是4位数就输出,你的卡号非法!
2.十位上的数字为8的中奖!中奖输出:恭喜您中奖了!
3.没有中奖的输出,很遗憾您没有中奖!
感谢高手们 ,我刚刚学习! 大家多多指教!
程序代码:#include <stdio.h>
#include <string.h>
int main(void)
{
char a[10] = {0};
while(EOF != scanf("%s",a))
{
if(strlen(a) != 4)
{
printf("数据非法!\n");
memset(a,0,sizeof(a));
}
else
break;
}
if(a[0] == '8')
printf("中奖!\n");
else
printf("没中奖!\n");
return 0;
}
