GAME1 - #include<stdio.h> #include<stdlib.h>...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<stdio.h> #include<stdlib.h> #include<dos.h> #include<conio.h> #include<string.h> #define F1 for(a=0;a<4;a++) #define F2 for(b=0;b<4;b++) #define ERROR printf("\a") void output (void); int getkey (void); int arr[4][4]={{4,1,3,5}, {2,10,15,14}, {6,9,7,8}, {12,13,11,32} }; void main (void) { int temp,a,b; int key; char name[90]; clrscr(); textcolor(7); cprintf("Enter your name:"); textcolor(3); gets(name); textcolor(7); clrscr(); output(); a=b=3; while (arr[0][0]!=1 || arr[0][1]!=2 || arr[0][2]!=3 || arr[0][3]!=4 || arr[1][0]! =5 || arr[1][1]!=6 || arr[1][2]!=7 || arr[1][3]!=8 || arr[2][0]!=9 || arr[2][1]!=10 || arr[2][2]!=11 || arr[2][3]!=12 || arr[3][0]!=13 || arr[3][1]!=14 || arr[3][2]! =15 || arr[3][3]!=32 ) { key=getkey(); if(key==77) { if(b-1<0) ERROR; else { temp=arr[a][b]; arr[a][b]=arr[a][b-1]; arr[a][b-1]=temp; b--; } } if(key==75) { if(b+1>3) ERROR; else { temp=arr[a][b]; arr[a][b]=arr[a][b+1]; arr[a][b+1]=temp; b++; }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
} if(key==72) { if(a+1>3) ERROR; else { temp=arr[a][b];
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/06/2010 for the course UBIT 411 taught by Professor Saleemelahi during the Spring '10 term at University of Karachi.

Page1 / 5

GAME1 - #include&lt;stdio.h&gt; #include&lt;stdlib.h&gt;...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online