问题遇到的现象和发生背景 随机数num1,一直与输入的num2相同
用代码块功能插入代码,请勿粘贴截图 #include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
srand((unsigned int)time(NULL)*10);
int num1 = rand() %32 + 1;
int num2;
int cs = 0;
printf("Please enter a number in 1-32, which you think is the same with computer:\n");
scanf("%d",&num2);
if (num1 = num2)
{
cs++;
printf("You are correct!\n");
}
else
{
cs++;
printf("You are wrong!Try again.");
do{
printf("Please enter a number, which you think is the same with computer:\n");
scanf("%d",&num2);
printf("You are wrong again!");
cs++;
} while(num1 = num2);
do{
printf("Let us try again! You have got a lot of mistakes.");
cs=0;
do{
printf("Please enter a number, which you think is the same with computer:\n");
scanf("%d",&num2);
printf("You are wrong again!");
cs++;
} while(num1 = num2);
} while(cs < 4);
}
printf("Your grades is %d.",cs);
return 0;
}