Half Monk 697 Report post Posted August 9, 2013 Here is the source code for c++. #?include?<iostream.h> //opening headerfile iostream for in-out#include<conio.h> //opening headerfile conio for clrscr();#include<stdlib.h> //opening headerfile stdlib forchar tic[3][3]; //global matrix declerationsint d,e,f,a,t,i,j,x,y; //global variables declerationsvoid display(); //displays the matrixvoid user(); //function for user's movevoid newdisp(); //function for display of matrix after every movevoid pc(); //function for pc's moveint check(); //function for finding out the winnerint horcheck(); //function for horizontal line checkint vercheck(); //function for vertical line checkint diagcheck(); //function for diagonal line checkmain() //main function{clrscr(); //clears the previous output screenrandomize(); //initialize random function callingint d=random(2); //random function callfor(i=0;i?;i++)for(j=0;j?;j++)tic[j]=' '; //assigning space ' ' to all elements of matrixdisplay(); //display function callif(d==0){user();}else{ pc();} //random starting of the game dependingogetch(); //provides output by getting input withoutreturning to programreturn 0; //return int to main function}void display() //display function definition{for(t=0;t?;t++){cout<<" "<<tic[t][0]<<" | "<<tic[t][1]<<" | "<<tic[t][2]<<endl; //figure formationif(t!=2)cout<<" --|---|--"<<endl;}}void user() //user function definition{cout<<endl<<endl<<endl;cout<<"ENTER THE CO-ORDINATES WHERE YOU WANT TO PUT UR 'X'";cout<<endl<<"Enter x(co-ordinate)";cin>>x;cout<<endl<<"Enter y(co-ordinate)";cin>>y;cout<<"Values are"<<x<<y;cout<<endl;if((x<0)||(x>2)&&(y<0)||(y>2)) //check for valid co-ordinates{cout<<" ENTER THE CORRECT CO-ORDINATES"<<endl;user(); //user function call}else{if(tic[x][y]==' ') //check for vacant space at entered co-ordinates{tic[x][y]='X'; //assigning user 'X' to the co-ordinatesnewdisp(); //newdisp function call}else{ 2 Share this post Link to post Share on other sites