小时候玩过一个小游戏(从1开始轮流数数,二个人,每个人至多可以数1-3个数,谁先数到最后一个数30谁就嬴),想用C语言编写出来.但是写出来之后却出现问题?只输出前一次的数?希望哪位可以帮帮忙?谢谢!最后祝各位圣诞节快乐!!!!
#include<stdio.h>
#define Y 1
#define N 0
void xianshi(int i)
{
for(i=1;i<=30;i++)
{
printf("%2d\t",i);
if((i%10)==0)
printf("\n");
}
}
void youxi()
{
int j,m,yn,n,a[30],b[30];
for(j=1;j<=30;j++)
a[j-1]=j;
yn=Y;
while(yn)
{
printf("The game start:");
printf("please input 1-3 numbers:");
for(m=0;m<=30;m+4)
{
if(a[m]==scanf("%d",&b[m]))
for(n=m+1;n<=m+3;n++)
printf("%d\t%d\t%d",a[m+1],a[m+2],a[m+3]);
else if(a[m]==scanf("%d",&b[m])&&a[m+1]==scanf("%d",&b[m+1]))
for(n=m+2;n<=m+3;n++)
printf("%d\t%d",a[m+2],a[m+3]);
else if(a[m]==scanf("%d",&b[m])&&a[m+1]==scanf("%d",&b[m+1])&&a[m+2]==scanf("%d",&b[m+2]));
printf("%d",a[m+3]);
}
if(a[29]==scanf("%d",&b[29]))
printf("congratulations");
printf("another game yn=Y/N:");
if(getchar())
yn=Y;
else
yn=N;
}
}
int main()
{
int i;
printf("\t\t------------**************------------\n");
xianshi(30);
youxi();
getch();
return;
}
[此贴子已经被作者于2006-12-21 23:13:20编辑过]