📄 24点扑克牌游戏.htm
字号:
gdriver,gmode;<BR>gdriver=DETECT;<BR>initgraph(&gdriver,&gmode,"d:\\turboc2");<BR>cleardevice();<BR>}<BR>void
close()<BR>{<BR>closegraph();<BR>}<BR>void
change(char
stm[]) /*将表达式的输出类型进行转换*/<BR>{int
i=0,j=0;<BR>char
ch;<BR>initstack(L);<BR>ch=stm[i];<BR>while(ch!='\0')<BR>{<BR> while(isdigit(ch)||ch='.')<BR> {<BR> after[j]=ch;<BR> j++;<BR> ch=stm[++i];<BR> }<BR> switch(ch)<BR> {<BR> case
'+':<BR> case
'-':<BR> while(L->top!=0&&L->stack[L->top]!='(')
<BR> {<BR> after[j]=L->stack[L->top];<BR> j++;<BR> L->top--;<BR> }<BR> L->top++;<BR> L->stack[L->top]=ch;<BR> break;<BR> case
'*':<BR> case
'/':<BR> while(L->stack(L->top)=='*'||L->stack[L->top]='/')<BR> {<BR> after[j]=L->stack[L->top];<BR> j++;<BR> L->top--;<BR> }<BR> L->top++;<BR> L->stack[L->top]=ch;<BR> break;<BR> case
'(':<BR> L->top++;<BR> L->stack[L->top]=ch;<BR> break;<BR> case
')':<BR> while(L->stack[L->top]!='('&&L->top!='\0')<BR> {<BR> after[j]=L->stack[L->top];<BR> j++;<BR> L->top--;<BR> }<BR> if(L->top==0)<BR> {<BR> printf("wrong
input
format!\n");<BR> exit(0);<BR> }<BR> L->top--;<BR> break;<BR> case
'
':<BR> break;<BR> default:<BR> printf("the
express include illegal
character!\n");<BR> exit(0);<BR> }<BR> i++;<BR> ch=stm[i];<BR>}<BR>while(L->top!=0)<BR>{<BR> after[j]=L->stack[L->top];<BR> j++;<BR>}<BR>after[j]='\0';<BR>printf("the
changed expression is:");<BR>puts(after);
<BR>printf("\n");<BR>}<BR>int
compute() /*计算表达式的值*/<BR>{<BR>int
m=0,n;<BR>char
ch;<BR>initstack1(S);<BR>ch=after[m];<BR>while(ch!='\0')<BR> {<BR> if(isdigit(ch))<BR> {<BR> n=0;<BR> do<BR> {<BR> n=10*n+ch-'0';<BR> ch=after[++m];<BR> }while(ch!='.')<BR> switch(ch)<BR> {<BR> case
'+':<BR> S->stack1[S->top-1]=S->stack1[S->top-1]+S->stack1[S->top];<BR> S->top--;<BR> break;<BR> case
'-':<BR> S->stack1[S->top-1]=S->stack1[S->top-1]-S->stack1[S->top];<BR> S->top--;<BR> break;<BR> case
'*':<BR> S->stack1[S->top-1]=S->stack1[S->top]*S->stack1[S->top-1];<BR> S->top--;<BR> break;<BR> case
'/':<BR> S->stack1[S->top-1]=S->stack1[S->top-1]/S->stack1[S->top];<BR> S->top--;<BR> break;<BR> }<BR> ch=after[++m];<BR>}<BR>return
S->stack1[S->top];<BR>}<BR><BR>main()<BR>{<BR>int
i,result;<BR>char ch;<BR>int
gdriver,gmode;<BR>clrscr();<BR>init(); /*图形初始化*/<BR>while(1)<BR>{<BR>setbkcolor(BLACK);<BR>cleardevice();<BR>play();<BR>gotoxy(1,15);<BR>printf("-----------------------------------note------------------------------------------------\n"); /*表达式的输入*/<BR>printf("Please
enter express include only four
numbers:\n");<BR>printf("Format as
follows:2.*(3.+5.)/2.\n");<BR>printf("-----------------------------------------------------------------------------------------\n");<BR>gets(str);<BR>change(str);<BR>result=compute();<BR>if(result==24)<BR> text1("VERY
GOOD!!!");<BR>else<BR>text1("WRONG!!!");<BR>printf("continue?(Y
or
N)\n");<BR>scanf("%c",&ch);<BR>if(ch=='N'||ch=='n')<BR>break;<BR>}<BR>close(); /*关闭图形*/<BR>return;<BR>}
<BR></FONT></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD width="100%" height=25>
<DIV align=center></DIV></TD></TR>
<TR>
<TD width=255 height=20><A class=bottom
href="http://www.cstudyhome.com/wenzhang06/review.asp?NewsID=5430"
target=_blank> <IMG
height=18 src="24点扑克牌游戏_files/icon1.gif" width=18
border=0> <FONT color=blue>发表评论</FONT></A> </TD></TR>
<TR>
<TD width="100%">
<HR SIZE=1>
</TD></TR>
<TR>
<TD height=8></TD></TR>
<TR>
<TD width="100%" height=18><B>相关专题:</B>
<TR>
<TD width="100%">
<HR SIZE=1>
</TD></TR>
<TR>
<TD height=8></TD></TR>
<TR>
<TD width="100%" height=18><B>相关信息:</B></TD></TR>
<TR>
<TD height=8></TD></TR>
<TR>
<TD width="100%"> 没有相关信息</TD></TR>
<TR>
<TD width="100%">
<HR SIZE=1>
</TD></TR>
<TR>
<TD height=8></TD></TR>
<TR>
<TD width="100%"><B>相关评论:</B></TD></TR>
<TR>
<TD height=8></TD></TR>
<TR>
<TD width="100%"></TD></TR>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=5 width="100%"
border=0>
<TBODY>
<TR bgColor=#d1e4fc>
<TD
width="100%">发表人:里比较喀什大后方 发表人邮件:<A
href="mailto:sdfkhd@.163.com">sdfkhd@.163.com</A> 发表时间:2005-5-8
15:59:56</TD>
<TD width=270>
<P align=right></P></TD></TR>
<TR>
<TD bgColor=#ffffff colSpan=2>我看不懂
</TD></TR></TD></TR></TBODY></TABLE>
<HR noShade SIZE=1>
</TD></TR>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=5 width="100%"
border=0>
<TBODY>
<TR bgColor=#d1e4fc>
<TD width="100%">发表人:子恒 发表人邮件:<A
href="mailto:ziheng0706@sina.com">ziheng0706@sina.com</A> 发表时间:2005-5-11
17:35:54</TD>
<TD width=270>
<P align=right></P></TD></TR>
<TR>
<TD bgColor=#ffffff colSpan=2>有这么复杂吗?我有些不懂!
</TD></TR></TD></TR></TBODY></TABLE>
<HR noShade SIZE=1>
</TD></TR>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=5 width="100%"
border=0>
<TBODY>
<TR bgColor=#d1e4fc>
<TD
width="100%">发表人:傲视孤星 发表人邮件:<A
href="mailto:116059120qq.com">116059120qq.com</A> 发表时间:2005-5-25
23:58:12</TD>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -