bshy.net
当前位置:首页>>关于C语言编写猜数字游戏的资料>>

C语言编写猜数字游戏

#include #include #include int main() { int i,a,n; srand((int)time(NULL)); n=rand()%100+1; for(i=0; i

#include #include #include #include void main() { intA=0,B,i,j,k=0,a[5],g[5]; printf("请输入你猜测的一个5位数数字\n"); scanf("%d",&k); while(k99999) { printf("你输入了一个非常规数据,请重新输入\n"); scanf("%d",&k); } srand((uns...

#include #include #include int main(){srand((unsigned)time(0));int count=5;int n=rand()%99+1,in;while(count>0){printf("请输入你猜的数:");fflush(stdin);scanf("%d",&in);if(in==n){printf("\n恭喜你猜对了!\n");getchar();exit(0);}els...

#include int main(){ int n;while(scanf(" %d",&n)==1){ int m; while(scanf("%d",&m)==1 && m!=n) { if(n>m) printf("too small\n"); else printf("too low\n"); } printf("right\n");}return 0;}

#include#include#includeint main(){ int n,m,i = 0; srand(time(NULL)); n = rand()%100+1; do { printf("输入所猜数字:"); scanf("%d",&m); i++; if( m>n ) printf("猜错了!太大了!\n"); else if( m < n) printf("猜错了!太小了!\n"); }w...

#include #include #include int main() { int i,a,n; srand((int)time(NULL)); n=rand()%100+1; for(i=0; i

#include #include #include void main() { int i,j; srand((unsigned)time(NULL)); i=rand()%100; print("猜电脑出的一个100内的数:/n"); while(true) { scanf("%d/n",&j); if(j==i) {print("猜中了,游戏结束/n");break;} print("没猜中。请...

已经改正,如下: #include #include #include void circle(int i) { int n ; printf("请输入您所猜的数字(0-100) \n"); scanf("%d",&n); if(in) { printf("the number is smaller.input agine \n"); circle(i); } if(i==n)//?不是 printf("the ...

#include //为获得随机数#include //获取时间void main(){ int a,b; srand(time(0)); a=1+(rand()%100); //获得一个100以内的随机数 while(1) { printf("猜一猜是多少:"); scanf_s("%d",&b); if(ba) { printf("输入的太大了.\n"); } else { pri...

#include #include #include #define GUESS_TIME 10 //最多可猜的次数#define MAX_NUM 100 //数字范围int main(){ int times; int num, guess_num; char order; while((order = getchar()) != 'q') { times = 0; printf("GAME_START\n"); srand(...

网站首页 | 网站地图
All rights reserved Powered by www.bshy.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com