第四章程序的控制结构(第二讲4[1].4~4.5).pptVIP

  • 16
  • 0
  • 约9.69千字
  • 约 47页
  • 2017-05-20 发布于四川
  • 举报

第四章程序的控制结构(第二讲4[1].4~4.5).ppt

实验3 #include stdlib.h #include stdio.h #include time.h main() { int magic; int guess; int counter; srand(time(NULL)); magic = rand() % 100 + 1; counter = 0; do{ printf(Please guess a magic number:); scanf(%d, guess); counter ++; if (guess magic) printf(Wrong! Too high!\n); else if (guess magic) printf(Wrong! Too low!\n); }while ((guess != magic) (counter 10)); printf(Right!\n); printf(counter = %d \n, counter); } 存在一个错误 最多猜10次 实验3 #include

文档评论(0)

1亿VIP精品文档

相关文档