菜鸟的c++问题

来源:百度知道 编辑:UC知道 时间:2024/05/22 14:15:55
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main()
{
int a , b , c, d , y , n ;
srand(time(NULL));
c = rand()%100 + 1;
do
{
for(a=1;a<=7;a++)
{
printf("Enter a number:");
scanf("%d",&b);
if (b == c)
printf("Hooray , you have won!");
break;
else if (b < c)
{
printf("Wrong number , try again.");
printf("/nYour guess is too low.");
}
else if (b > c)
{
printf("Wrong number , try again.");
printf("/nYour guess is too high.");
}
}
printf("Would you like to play again<y/n>:");
scanf("%c",&d);
if(d == n)
break;
}
while (d == y);
return 0;
}
老师布置的作业,关于猜数问题的程序,这是我打的程序,哪里有问题?感激不尽,告诉我哪里出问题就行了

#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main()
{
int a , b , c;
char d;
srand((int)time(0));
c = rand()%100 + 1;
do
{
for(a=1;a<=7;a++)
{
printf("Enter a number:");
scanf("%d",&b);
if (b == c)
{
printf("Hooray , you have won!");
break;
}
else if (b < c)
{
printf("Wrong number , try again.");
printf("\nYour guess is too low.");
}
else if (b > c)
{
printf("Wrong number , try again.");
printf("\nYour guess is too high.");
}
}
printf("\nWould you like to play again<y/n>:");
scanf("%c",&d);
if(d == 'n')
break;
}while (