分享好友 天南地北首页 网站导航

C语言简单问题——猜数字

网友发布 2023-06-29 02:37 · 头闻号游戏应用

干嘛要0表示输入结束 - -!

main()

{

int i,j;

int a[6][33]={{1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63},

{2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31,34,35,38,39,42,43,46,47,50,51,54,55,58,59,62,63},

{4,5,6,7,12,13,14,15,20,21,22,23,28,29,30,31,36,37,38,39,44,45,46,47,52,53,54,55,60,61,62,63},

{8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31,40,41,42,43,44,45,46,47,56,57,58,59,60,61,62,63 },

{16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63},

{32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63},

};

printf("请输入两位整数: ");

scanf("%d %d",&i,&j);

printf("结果是:%dn",a[i-1][j-1]);

}

如输入1 2 回车 结果是3

#include "stdio.h"

#include "time.h"

#include "stdlib.h"

int main(int argc, char* argv[])

{

int r;

int g;

srand(time(0));

r = rand()%1000;//产生一个小于1000的随机数,让大家猜

printf("请输入你猜的数:");

scanf("%d",&g);

while(g != r)//没猜中就循环

{

if(g > r)

{

printf("大了,请重新输入:");

}

else if(g < r)

{

printf("小了,请重新输入:");

}

scanf("%d",&g);

}

printf("不大不小n");

return 0;

}

免责声明:本平台仅供信息发布交流之途,请谨慎判断信息真伪。如遇虚假诈骗信息,请立即举报

举报
反对 0
打赏 0
更多相关文章

收藏

点赞