Matlab编写的猜数字游戏(11页).doc
《Matlab编写的猜数字游戏(11页).doc》由会员分享,可在线阅读,更多相关《Matlab编写的猜数字游戏(11页).doc(11页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、-Matlab编写的猜数字游戏 一个猜数字的游戏,先随机生成一个1到100之间的整数,由游戏者来猜此数,当输入的数过大,会提示数字大了,当输入的数过小,会提示数字小了,当猜中此数,游戏结束。好玩而已,呵呵,欢迎共同学习,email:slqinyifunction caishuzi(arg)if nargin < 1arg = 'newgame'endif strcmp(arg,'newgame')clf% set(gcf,'resize','off'); % 禁止调整窗口的大小set(gcf,'name',&
2、#39;猜数字 Version 1.0') % 修改标题栏set(gcf,'numbertitle','off') % 去掉标题栏中的 figure 1num = randint(1,1,100); % 随机产生个一小于100的正整数h_casu = uicontrol(gcf,'style','edit',.'unit','normalized','position',0.8,0.75,0.08,0.1,.'BackgroundColor',1,1,1,
3、39;ForegroundColor',0 0 1,.'fontsize',12,'visible','off','string',num2str(num),'tag','t_casu'); h_suru = uicontrol(gcf,'style','edit',.'unit','normalized','position',0.8,0.75,0.08,0.1,.'BackgroundColor
4、9;,1,1,1,'ForegroundColor',0 0 1,.'fontsize',12,'tag','t_suru');h_jisu = uicontrol(gcf,'style','edit',.'unit','normalized','position',0.75,0.75,0.08,0.1,.'BackgroundColor',1,1,1,'ForegroundColor',0 0 1,.'font
5、size',12,'visible','off','string',num2str(0),'tag','t_jisu');wz_string = '请输入一个整数(1100):'h_wenz = uicontrol(gcf,'style','text',.'unit','normalized','position',0.12,0.75,0.65,0.1,.'BackgroundColor',1,1
6、,1,'ForegroundColor',0 0 1,.'fontsize',24,'string',wz_string,'tag','t_wenz');cs_string = '您已输入的次数为 0 次'h_cisu = uicontrol(gcf,'style','text',.'unit','normalized','position',0.12,0.6,0.65,0.1,.'BackgroundColor
7、',1,1,1,'ForegroundColor',0 0 1,.'fontsize',24,'string',cs_string,'tag','t_cisu');h_newg = uicontrol(gcf,'style','pushbutton',.'unit','normalized','position',0.34,0.15,0.17,0.1,.'BackgroundColor',1,1,1,'F
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Matlab 编写 数字 游戏 11
限制150内