#include#includeint main(void)
{
int guess,magic,counter = 0;
int seed; //設(shè)置一個(gè)隨機(jī)的種子
char reply; //記錄用戶的選擇
printf("Please enter seed:\n");
scanf("%d",&seed);
srand(seed);
for(int i = 0;i<30;i++)
{
magic = rand()%100+1;
printf("%d ",magic);
if(i % 4 == 0)
putchar('\n');
}
putchar('\n');
do{
counter = 0;
magic = rand()%100+1;
do{
counter++;
printf("Please guess number:\n");
scanf("%d",&guess);
if(guess >magic){
printf("Wrong!Too big!\n");
}
else if(guess< magic){
printf("Wrong!Too small!\n");
}
else
{
printf("Right!\n");
}
}while(guess != magic && counter< 10); //限制猜的次數(shù)
printf("counter = %d\n",counter);
printf("Do you want to continue(y/n or Y/N)?");
scanf(" %c",&reply); //%c前有個(gè)空格 為了避免回車(chē)符讀給reply
}while(reply == 'y' || reply == 'Y');
return 0;
}
你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級(jí)流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級(jí)服務(wù)器適合批量采購(gòu),新人活動(dòng)首月15元起,快前往官網(wǎng)查看詳情吧