GAME3 - { if(arr[a][b]=='X' || arr[a][b]=='O')

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

View Full Document Right Arrow Icon
#include<stdlib.h> #include<stdio.h> #include<conio.h> #define F1 for(a=0;a<3;a++) #define F2 for(b=0;b<3;b++) #define ERROR printf("\a") void output (void); void cursor (int); int getkey(void); char arr[3][3]= {{'1','2','3'}, {'9','5','4'}, {'7','8','6'} }; int a,b,x,y; void main (void) { int key; clrscr(); x=y=0; gotoxy(2,1); printf("%c",45); //while(!(arr[0][0]=='x' && arr[0][1]=='x'&& arr[0][2]=='x') || !(arr[1][0]=='x' { key=getkey(); if(key==72 || key==75 || key==77 || key==80) cursor(key); output(); } getch(); } void output(void) { F1 { F2
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { if(arr[a][b]=='X' || arr[a][b]=='O') printf(&quot;%-8c&quot;,arr[a][b]); } printf(&quot;\n\n&quot;); } for(a=1;a&lt;18;a++) { gotoxy(a,2); printf(&quot;%c&quot;,196); gotoxy(a,4); printf(&quot;%c&quot;,196); } for(a=1;a&lt;6;a++) { gotoxy(5,a); printf(&quot;%c&quot;,179); gotoxy(12,a); printf(&quot;%c&quot;,179); } gotoxy(5,2); printf(&quot;%c&quot;,197); gotoxy(12,2); printf(&quot;%c&quot;,197); gotoxy(5,4); printf(&quot;%c&quot;,197); gotoxy(12,4); printf(&quot;%c&quot;,197); } int getkey (void) { int a,b; a=getch(); if(a==0) { b=getch(); return(b); } else if(a==81 || a==113) exit(0); return(0); } void cursor(int temp) { if(temp==72) { if(y-1&lt;0) ERROR; else y--; } if(temp==75) { if(x-1&lt;0) ERROR; else x--; } if(temp==77) { if(x+1&gt;2) ERROR; else { x++; gotoxy(8+x,1); printf(&quot;%c&quot;,45); } } if(temp==80) { if(y+1&gt;2) ERROR; else y++; } }...
View Full 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 / 3

GAME3 - { if(arr[a][b]=='X' || arr[a][b]=='O')

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