疑问三

来源:互联网 发布:手机数据分区损坏修复 编辑:程序博客网 时间:2024/05/29 17:44

#include<stdio.h>
#include<stdlib.h>
main()
{
 int guess;
 int magic;
 int counter;
 magic = rand();
 printf("Please guess a number:");
 scanf("%d",&guess);
 for(counter = 0;guess == magic;counter ++)
 {
  if(guess > magic)
  printf("Wrong!Too big");
  else
  printf("Wrong!Too big");
 }
 printf("counter = %d\n",counter);
}

问题:不管输入什么数字,输出都是“Right!”

疑问:原因应该是for语句没有被执行,但为何不被执行?

1 0
原创粉丝点击