ហ្គេមចងចាំ

នេះ​គឺ​ជា​ហ្គេម​តំ​រូវ​អោយ​យើង​ធ្វើ​ការ​​រក​គូ​របស់លេខ​​! ​ លេខ​០​ទាំង​អស់​នេះ​តំ​ណាង​ប្រ​អប់​ដែល​មិន​ទាន់​បាន​បើក​ បើ​យើង​ចង់​បើក​វា​យើង​គ្រាន់​តែ​ចុច​ enter វា​និង​បង្ហាញ​នូវ​លេខ​ដែល​មាន​នៅ​ខាង​ក្នុង​ប្រ​អប់​នោះ​ជា​មិន​ខាន់​ ការ​បើក​ប្រ​អប់​ចំ​នួន​២​លើក​ ​បើ​ការ​បើក​លើ​ក​ទី​១​ និង​លើក​ទី​២​មាន​លេខ​មិន​ដូច​គ្នា​ទេ​ វា​និង​បិទ​​លេខ​ដែល​បង្ហាញ​នោះ​ទៅ​វិញ​ដោយ​បង្ហាញ​លេខ​០ តែ​បើ​​ការ​បើក​ទាំង​២​លើក​មាន​លេខ​ដូច​គ្នា​ វា​និង​បង្ហាញ​លេខ​នោះ​​រហូត​។

ពេល​ដែល​យើង​ចាប់​ផ្តើម​លេង​ វា​និង​បង្ហាញ​លេខ​ដែល​មាន​នៅ​ក្នុង​គ្រប់​ប្រ​អប់​បន្តិច​សិន​រួច​ហើយ​ទើប​​ចាប់​ផ្តើម​លេង

ចំ​ណាំៈ​ ដើម្បី​ធ្វើ​ការ​ move យើង​ប្រើ​ w,a,s,d យើង​ត្រូវ​លេង​វា​តាម​tc មិន​ត្រូវ​បើ​ក​ការ​ file exeទេវា​ត្រូវ​ការ​​ screen ធំ​

#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<dos.h>
void main()
{       clrscr();
int r=10,c=10,i,j,b[10][10],x=0,y=0,count=0,x1,x2,y1,y2,win=0;
char ch=27;
_setcursortype(_NOCURSOR);
char level[3][10]={“ Easy” ,” Medium” ,” Hard” },levelch;
int levelmove=0;
do
{    for(i=0;i<3;i++)
if(levelmove==i)
{    textcolor(RED);
cprintf(“ \n\n\r\r%s” ,level[i]);
}
else
{    textcolor(WHITE);
cprintf(“ \n\n\r\r%s” ,level[i]);
}
levelch=getch();
switch(levelch)
{    case ‘w’:    levelmove–;break;
case ‘s’:    levelmove++;break;
case 13:        goto daro;
}
if(levelmove>=3)
levelmove=0;
if(levelmove<0)
levelmove=2;
clrscr();
}while(1);
daro:
int a[10][10];
if(levelmove==0)
{    int  a0[10][10]={    {1,5,1,5,2,4,1,2,1,5},
{1,3,3,2,4,5,1,3,1,3},
{2,2,4,2,5,3,5,5,2,4},
{1,1,3,5,4,2,1,3,5,5},
{2,3,3,1,4,2,1,3,1,5},
{1,2,4,3,4,1,3,4,2,4},
{3,2,4,5,1,2,3,3,2,1},
{2,4,2,5,3,4,5,4,1,4},
{4,3,5,4,5,3,2,1,5,5},
{2,2,4,5,3,4,4,1,3,5},
};
for(i=0;i<10;i++)
for(j=0;j<10;j++)
a[i][j]=a0[i][j];
}
else if(levelmove==1)
{     int     a1[10][10]={    {4,2,1,5,4,4,5,4,7,5},
{2,3,4,2,1,5,4,3,5,6},
{3,5,4,2,1,3,5,3,4,1},
{6,7,3,5,1,4,3,2,2,5},
{6,4,7,3,5,6,1,2,6,4},
{7,3,2,6,6,7,1,6,4,2},
{6,5,6,7,7,1,7,1,6,1},
{7,4,7,5,5,1,6,3,3,2},
{6,1,2,7,2,1,7,2,3,3},
{7,1,5,7,6,1,1,2,4,3},
};
for(i=0;i<10;i++)
for(j=0;j<10;j++)
a[i][j]=a1[i][j];
}
else if(levelmove==2)
{      int    a2[10][10]={    {6,1,5,4,3,9,5,10,6,2},
{10,3,3,6,9,9,8,2,5,3},
{7,4,3,4,2,10,4,3,2,5},
{2,1,6,10,9,1,5,1,4,5},
{7,3,8,1,7,2,10,4,5,6},
{6,4,3,5,8,1,10,1,4,5},
{7,8,6,5,1,2,10,3,6,8},
{1,2,7,2,8,9,6,10,4,9},
{9,9,7,10,2,7,3,7,8,7},
{8,1,8,7,9,8,6,4,9,10},
};
for(i=0;i<10;i++)
for(j=0;j<10;j++)
a[i][j]=a2[i][j];
}
clrscr();
for(i=0;i
{    for(j=0;j<c;j++)
{          b[i][j]=0;
printf(“ %5d” ,a[i][j]);
}
printf(“ \n\n\n\n” );
}
delay(1000);
clrscr();
do
{        for(i=0;i<r;i++)
for(j=0;j<c;j++)
if(a[i][j]==b[i][j])
win++;
if(win==(c*r))
{      clrscr();
textcolor(RED+128);
cprintf(“ Congratulation \n\rYou win!” );
cprintf(“ \n\rThank for playing” );
cprintf(“ \n\rPress any key to exit” );
getch();
exit(1);
}
else
win=0;
for(i=0;i<r;i++)
{    for(j=0;j<c;j++)
if(i==x&&j==y)
{    textcolor(RED);
cprintf(“ %5d” ,b[i][j]);
}
else
{       textcolor(WHITE);
cprintf(“ %5d” ,b[i][j]);
}
printf(“ \n\n\n\n” );
}

ch=getch();
switch(ch)
{
case ‘d’:y++;
break;
case ‘s’:x++;
break;
case ‘a’:y–;
break;
case ‘w’:x–;
break;
case 13: if(count==0&&b[x][y]==0)
{    count=1;
x1=x;y1=y;
b[x][y]=a[x][y];
}
else if(count==1&&b[x][y]==0)
{      if(x1==x&&y1==y)
break;
b[x][y]=a[x][y];
clrscr();
for(i=0;i<r;i++)
{    for(j=0;j<c;j++)
if(x==i&&y==j)
{    textcolor(RED);
cprintf(“ %5d” ,b[i][j]);
}
else
{    textcolor(WHITE);
cprintf(“ %5d” ,b[i][j]);
}
printf(“ \n\n\n\n” );
}
delay(400);
if(b[x1][y1]!=b[x][y])
{    b[x1][y1]=0;
b[x][y]=0;
}
count=0;
}

break;
}
if(y<0)   y=c-1;
if(y>c-1) y=0;
if(x<0)   x=r-1;
if(x>r-1) x=0;
clrscr();
}while(ch!=27);
getch();
}

អរគុណចំពោះ ដារ៉ូ មិត្ត​សម្លាញ់ដែល​បាន​ចែកនូវរំលែកកម្មវិធីនេះដល់ខ្ញុំ

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s