#include <stdio.h>
int main(){
srand(time(0));
int number = rand()%100+1;
int count = 0;
int a = 0;
printf("******************************************\n");
printf("*****|||||||||||||幸运数|||||||||||||*****\n");
printf("*****|||你有七次机会猜对这个幸运数|||*****\n");
printf("*****|||范围是‘1——100’祝你好运|||*****\n");
printf("******************************************\n");
printf("******************************************\n\n\n");
do{
printf("输入数字:");
scanf("%d",&a);
if(a==50&&number!=50&count==0){
printf("Eevee:你是瞎蒙的,还是真懂?\n");
}
if(count==1){
if(a==75&&number>50){
printf("Eevee:看来你是老懂哥了,看看你的运气如何吧!\n");
}
else if(a==25&&number>50){
printf("Eevee:你搞错了吧!\n");
}
else if(a==75&&number<50){
printf("Eevee:你搞错了吧!\n");
}
else if(a==25&&number<50){
printf("Eevee:看来你是老懂哥了,接下来看看你的运气如何吧!\n");
}
}
count ++;
if(a>number){
printf("***********************输入的数比幸运数大\n\n");
}else if (a < number ){
printf("***********************输入的数比幸运数小\n\n");
}
}while(a != number);
switch(count){
case 1:
printf("\n\n 你真是天选之子,一次就猜中了!幸运数是%d\n\n",a);
break;
case 2:
printf("\n\n 运气很好,两次就猜出!幸运数是%d\n\n",a);
break;
case 3:
printf("\n\n 运气不错,三次结束。幸运数是%d\n\n",a);
break;
case 4:
printf("\n\n 四次!幸运数是%d\n\n",a);
break;
case 5:
printf("\n\n 五次!幸运数是%d\n\n",a);
break;
case 6:
printf("\n\n 六次!幸运数是%d\n\n",a);
break;
case 7:
printf("\n\n 看来你完全懂了这个游戏规则,不过你运气挺差!");
printf("\n 但是有时候差到极致就是极好!\n\n");
break;
default:
printf("\n************************************************************\n");
printf("************************************************************\n");
printf(" 幸运数是%d,你用了%d次机会 \n",a,count);
printf(" 请以后保持思考,幸运女神不会眷顾傻瓜 \n");
printf("************************************************************\n");
printf("************************************************************\n");
}
return 0;
}
Lucky Number.c · Eevee/PTA_C - Gitee.comhttps://gitee.com/eevee14/pta/blob/master/Lucky%20Number.c