问题描述: C语言算法,随机猜测数字 1个回答 分类:综合 2014-12-09 问题解答: 我来补答 #include<stdio.h>#include<stdlib.h>int main(){\x09int i,count,n,m;\x09srand(time(NULL));\x09//以当前时间为随机数种子,以产生不同的随机数列\x09n=(rand(n)%100)+1;\x09count=1;\x09while(count<=10){\x09\x09printf("输入您的猜测数字(1~100):");\x09\x09scanf("%d",&m);\x09\x09if(m==n){\x09\x09\x09printf("恭喜您猜对了!总计猜%d次!\n",count);\x09\x09\x09return 0;\x09\x09}\x09\x09else if(m<n){\x09\x09\x09printf("太小,");\x09\x09}\x09\x09else{\x09\x09\x09printf("太大,");\x09\x09}\x09\x09printf("剩余%d次机会!\n",10-count);\x09\x09count++;\x09}\x09printf("超出尝试次数,游戏结束!\n");\x09return 0;} 展开全文阅读