编写猜数字小游戏 -电脑资料

电脑资料 时间:2019-01-01 我要投稿
【www.unjs.com - 电脑资料】

   

#include <stdio.h>#include <stdlib.h>#include<time.h>int main(){ int num = 0; srand((unsigned)time(NULL)); int ret = rand() % 100 + 1; while (1) {  printf("请猜数字:>");  scanf_s("%d",&num);  if (num == ret)  {   printf("猜对了\n");   break;  }  else if (num > ret)  {   printf("猜大了\n");  }  else  {   printf("猜小了\n");  } }  system("pause");  return 0; }

最新文章