ช่วยด้วยค่ะๆๆนะๆๆช่วยแก้โค้ดเกมส์ผลักFออกจากตาราง ภาษาซีหน่อยนะคะจะส่งแล้วค่ะทำไงดีช่วยหน่อยนะ

กระทู้คำถาม
ช่วยด้วยค่ะๆๆนะๆๆช่วยแก้โค้ดเกมผลักFออกจากตาราง
ภาษาซีหน่อยนะค่ะจะส่งแล้วค่ะทำไงดีช่วยหน่อยนะ ใครกรุณาก็เขียนตอบให้ด้วยนะค่ะเพราะจะส่งแล้วทำอยู่หลายครั้งก็ไม่ผ่านสักทีอยากจะร้องไห้แล้ว 😭😭😭😭


#include<stdio.h>
#include <stdlib.h>
#include<time.h>
char data[4][4];
char  box[4] = {'A','F','A','F'};
int score[2]={0,0},count=0;
int i ;
int j ;

void mono()
{
    printf("Player1 Score:%d     Player2 Score:%d :\n",score[0],score[1]);
    printf("row 1 2 3 4   \n");
    for( i=0;i<4;i++)
    {
        printf(" %d  ",i+1);
        for( j=0;j<2;j++)
        {
            if(j<4)printf("%d ",data[j]);

        }
        printf("\n");
    }
    printf("This is player %d Turn:\n",(count%2)+1);
}
void ClearScreen()
{
    system("@cls||clear");
}
void Check()
{
    int tscore=0,time=0,is2X2=0,isshift=1;
    int i ;
    int j ;
    while(isshift==1)
    {
       isshift=0;
        //check
        for( i=0;i<3;i++)
        {

            for( j=0;j<=3;j++)
            {
                if(i<=2)
                {
                    if(data[j]==data[i+1][j] && data[j]==data[i+2][j] && data[j]!=0)
                    {
                        isshift=1;
                        tscore+=1;
                        data[j]=0;
                        data[i+1][j]=0;
                        data[i+2][j]=0;
                    }
                }
                if(j<=2)
                {
                    if(data[j]==data[j+1]&&data[j]==data[j+2]&&data[j]!=0)
                    {
                        isshift=1;
                        tscore+=1;
                        data[j]=0;
                        data[j+1]=0;
                        data[j+2]=0;
                    }
                }
                if(i<=1)
                {
                    if(data[j]==data[i+1][j] && data[j]==data[i+2][j] && data[j]==data[i+3][j] && data[j]!=0)
                    {
                        isshift=1;
                        tscore+=2;
                        data[j]=0;
                        data[i+1][j]=0;
                        data[i+2][j]=0;
                        data[i+3][j]=0;
                    }
                }
                if(j<=1)
                {
                    if(data[j]==data[j+1]&&data[j]==data[j+2]&&data[j]==data[j+3]&&data[j]!=0)
                    {
                        isshift=1;
                        tscore+=2;
                        data[j]=0;
                        data[j+1]=0;
                        data[j+2]=0;
                        data[j+3]=0;
                    }
                }
                    if(i<=2&&j<=2)
                if(data[j]==data[i+1][j] && data[j]==data[j+1] && data[j]==data[i+1][j+1] && data[j]!=0)
                {
                    isshift=1;
                    is2X2++;
                    data[j]=0;
                    data[j+1]=0;
                    data[i+1][j]=0;
                    data[i+1][j+1]=0;
                }
            }
        }
        //Remove and Shift
        int i ;
        int j ;

        for( i=3;i>0;i--)
        {
            for( j=0;j<4;j++)
            {
                if(data[j]==0)
                {
                    //shift 0 to top
                    int shift=0;
                    while(data[i-shift][j]==0)
                    {
                        if(i-shift<=0)
                        {
                            shift=0;
                            break;
                        }
                        shift++;
                    }
                    int m ;
                    for( m=i;m>=shift;m--)
                    {

                        data[m][j]=data[m-shift][j];
                    }

                    for( m=0;m<shift;m++)
                    {

                        data[m][j]=0;
                    }
                }
            }
        }
        //replace 0

        for( i=3;i>=0;i--)for( j=0;j<4;j++)if(data[j]==0)data[j]=rand()%4+1;
    }
}
void ShiftR(int line)
{

    int i ;
    for( i=0;i<3;i++)
    {
        data[line-1]=data[line-1][i+1];
    }
    data[line-1][3]=box[0];

    for( i=0;i<3;i++)
    {
        box=box[i+1];
    }
    box[3]=rand()%4+1;
}
void ShiftL(int line)
{
    int i ;

    for( i=3;i>=1;i--)
    {
        data[line-1]=data[line-1][i-1];
    }
    data[line-1][0]=box[0];
    for( i=0;i<3;i++)
    {
        box=box[i+1];
    }
    box[3]=rand()%4+1;
}

int main()
{
    // สุ่มตาราง
    int i ;
    int j ;

    for( i=0;i<4;i++)
    {
        box=rand()%4+1;
        for( j=0;j<4;j++)
        {
            data[j]=rand()%4+1;
        }
    }
// check
    Check();
    score[0]=0;
    score[1]=0;
    count=0;
    //Start Game loop
    while(1)
    {

        ClearScreen();
        mono();
        if(score[0]>=30)
        {
            printf("Player 1 Win");
            break;
        }
        if(score[1]>=30)
        {
            printf("Player 2 Win");
            break;
        }
        //Input
        int r;
        char c[10];
        printf("Enter row:");
        scanf("%c",&c);
    }
}
// int bug becau
แก้ไขข้อความเมื่อ
แสดงความคิดเห็น
โปรดศึกษาและยอมรับนโยบายข้อมูลส่วนบุคคลก่อนเริ่มใช้งาน อ่านเพิ่มเติมได้ที่นี่