Popular Posts

Monday, April 7, 2014

Linked List Code c++

#include "iostream"
#include "stddef.h"
using namespace std;

template <class type>
class List;

template <class type>
class Node {
public:
    type data;
    Node * next;
    Node (type d);
};

template <class type>
Node<type>::Node(type d){
    data = d;
    next = NULL;
}

template <class type>
class List{
    Node<type> * root;
public:
    List();
    bool isFull();
    bool isEmpty();
    void print();
    bool insert(type info);
    void makeEmpty();
    bool Delete(type info);
    ~List();
};

template <class type>
List<type>::List(){
    root = NULL;
}

template <class type>
List<type>::~List(){
    makeEmpty();
}

template <class type>
bool List<type>::Delete(type info){
   
    if(!isEmpty()){
        Node<type> * previous = NULL;
        Node<type> * current;
        current = root;
       
        while(current && current->data != info){
            previous = current;
            current= current->next;
        }
        if(!previous){
            root = current->next;
        }
        else
        {
            if(current){
                previous->next = current->next;
            }
            else
                return false;
        }
        delete current;
        return true;
    }
    return false;
}

template <class type>
bool List<type>::insert(type info){
   
    if(!isFull()){
        Node<type> * newNode  = new Node<type>(info);
       
        Node<type> * previous = NULL;
        Node<type> * current;
        current = root;
       
        while(current && current->data < info){
            previous = current;
            current= current->next;
        }
        if(!previous){
            newNode->next = root;
            root = newNode;
        }   
        else
        {
            newNode -> next = current;
            previous -> next = newNode;
        }
        return true;
    }
    return false;
}

template <class type>
bool List<type>::isFull(){
    Node <type> * temp = new Node<type>(1);
    if(temp){
        delete temp;
        return false;
    }
    else
        return true;
}

template <class type>
bool List<type>::isEmpty(){
    if(root)
        return false;
    else
        return true;
}

template <class type>
void List<type>::print(){
    Node <type>* current = root;
    while(current){
        cout<<current->data<<endl;
        current = current -> next;
    }
}

template <class type>
void List<type>::makeEmpty(){
    Node <type>* current = root;
    Node <type>* temp;
    while(current){
        temp = current;
        current = current -> next;
        delete temp;
    }
}
void main(){
    List<int> obj;
    char ans = 'y';
    int data;
    while(ans!='n'){
        cout<<"Enter data to insert"<<endl;
        cin>>data;
        obj.insert(data);
        cout<<endl;
        cout<<"Press n to exit"<<endl;
        cin>>ans;
       
    }
    cout<<"List:"<<endl;
    obj.print();
    ans='y';
    while(ans!='n'){
        cout<<"Enter data to delete"<<endl;
        cin>>data;
        obj.Delete(data);
        cout<<endl;
        cout<<"Press n to exit"<<endl;
        cin>>ans;
        cout<<"List:"<<endl;
        obj.print();
    }
system("PAUSE");
}

Thursday, April 3, 2014

Source code c++

Priority queue C++ using linked list (sorted)

#include<iostream>
using namespace std;

struct node
{
    int data;
    node*next;

    node()
    {
        data=-1;
        next=NULL;
    }
    node(int n,node*temp)
    {
        data=n;
        next=temp;
    }
};
class queue
{
private:
    node*head;
    node*tail;

public:
    queue()
    {
        head=NULL;
        tail=NULL;
    }
bool enque(int data);
bool deque(int&data);
bool Isempty();
};
   
bool queue:: enque(int data)
    {
    node*temp=new node();

    if(temp==NULL) // if system memory is full return false
    {
        return false;
    }

    else // if system memory is not full then enque
    {

    if(head==NULL)
        {
           
            temp->data=data;
            temp->next=NULL;
            head=temp;
           
        }
        else if(head->next==NULL)
        {
            if(head->data<data)
            {
               
                temp->data=data;
                temp->next=head;
                head=temp;
            }
            else if(head->data>data)
            {
               
                temp->data=data;
                temp->next=NULL;
                temp->next=head->next;
                head->next=temp;
           
            }
        }

        else
        {
            node*current=head;
            if(head->data<data)
            {
               
                temp->data=data;
                temp->next=NULL;
                temp->next=head;
                head=temp;
               
            }
            else
            {
                while(current->next!=NULL)
                {
                    if(current->next->data<data)
                    {
                        break;
                    }
                    current=current->next;
                }
               
                temp->data=data;
                temp->next=current->next;
                current->next=temp;
            }
        }
        return true;
    }
}

bool queue:: deque(int&data)
    {
        node*current=head;
        if(current==NULL)
        {
            return false;
        }
        else
        {
            data=current->data;
            head=current->next;
            delete current;
            return true;
        }
    }

bool queue:: Isempty()
    {
        if(head==NULL)
        {
            return false;
        }
        else
        {
            return true;
        }
    }






void main()
{
    queue q;
    int option;
    int data;
    bool temp;
    while(1)
    {
        cout<<"Enter 1 to Enter data in queue"<<endl;
        cout<<"Enter 2 to Deque data in queue"<<endl;
        cout<<"Enter 3 to deque all elements"<<endl;
        cout<<"Enter 4 to clear screen"<<endl;

        cin>>option;

        switch(option)
        {
        case 1:
            cout<<"Enter data : ";
            cin>>data;
            if(q.enque(data))
            {
            cout<<"Succesfully enqueued"<<endl;
            }
            else
            {
                cout<<"system memory is full"<<endl;
            }
            break;
       
       
        case 2:
            if(q.Isempty())
            {
            temp=q.deque(data);
            cout<<"DEQUEUED DATA IS : "<<data<<endl;
            }
            else
            {
                cout<<"queue is Empty"<<endl;
            }
            break;
       
       
        case 3:
           
            if(q.Isempty())
            {
                while(q.Isempty())
            {
            temp=q.deque(data);
            cout<<"DEQUEUED DATA IS : "<<data<<endl;
            }
            }
            else
            {
                cout<<"queue is Empty"<<endl;
            }
            break;
       
        case 4:
            system("cls");
            break;

        case 5:
            cout<<"Invalid input "<<endl;
            break;



        }
   


        }

   

}

Tuesday, May 7, 2013

C++ Stack Code


#include<iostream>
using namespace std;

///////////////////////////////////// this is our stack class of type template ///////////////////////////////////////////////////

template <class type>
class Stack{
    int top;
    int max;
    type * array;
public:
    Stack(int n = 10);
    bool push (type data);
    bool pop(type & data);
    bool isFull();
    bool isEmpty();
    ~Stack();
};

template <class type>
Stack<type>::Stack(int n){
    top = -1;
    max = n;
    array = new type[max];
}

template <class type>
bool Stack<type>::push (type data){
    if(!isFull()){
        array[++top] = data;
        return true;
    }
    else
        return false;
}

template <class type>
bool Stack<type>::pop(type & data){
    if(!isEmpty()){
        data = array[top--];
        return true;
    }
    return false;
}
template <class type>
bool Stack<type>::isFull(){
    if(top == max-1)
        return true;
    else
        return false;
}
template <class type>
bool Stack<type>::isEmpty(){
    if(top==-1)
        return true;
    else
        return false;
}
template <class type>
Stack<type>::    ~Stack(){
    delete [] array;
}

////////////////////////////////////////////stack functions ends here ////////////////////////////////////////////////////

int main()
{


Stack<int> st; // this is how u instantiate a template stack in this exmple this become an integer stack

//Stack<char> st; //char stack
//Stack<bool> st; // boolian stack
//Stack<float> st; // float stack

st.push(10);
st.push(15);
st.push(16);
int temp=0;
st.pop(temp);
cout<<"Popped item : "<<temp<<endl;




system("PAUSE");

return 0;
}

Infix to post fix conversion

// implementation method
//1. Infix to post fix
// there will be two arrays. one will be inputed by user as infix expression and resulted post fix expression
// will be stored in 2nd array
// there will be a stack of template type
//  whenever a operand comes it will be stored in resulted array as it is. when ever a operator comes it will
// first pushed to stack(character type here). if the precedence of incoming operator is higher then present on
// of top of the stack then it will be pushed in stack when the precedence of incoming operator will be lower
// then at Top of the stack then all elements will poped and stored in resulted array
// in case of brackets. the program run on same algo as mentioned above on a little addition here was that
// whenever a closing bracket comes it will pop all element and stored in resulted array till it find the first
// bracket in stack(these brackets will not be stored in array)

#include<iostream>
#include<cstring>
using namespace std;

///////////////////////////////////// this is our stack class of type template ///////////////////////////////////////////////////

template <class type>
class Stack{
    int top;
    int max;
    type * array;
public:
    Stack(int n = 10);
    bool push (type data);
    bool pop(type & data);
    bool isFull();
    bool isEmpty();
    ~Stack();
};

template <class type>
Stack<type>::Stack(int n){
    top = -1;
    max = n;
    array = new type[max];
}

template <class type>
bool Stack<type>::push (type data){
    if(!isFull()){
        array[++top] = data;
        return true;
    }
    else
        return false;
}

template <class type>
bool Stack<type>::pop(type & data){
    if(!isEmpty()){
        data = array[top--];
        return true;
    }
    return false;
}
template <class type>
bool Stack<type>::isFull(){
    if(top == max-1)
        return true;
    else
        return false;
}
template <class type>
bool Stack<type>::isEmpty(){
    if(top==-1)
        return true;
    else
        return false;
}
template <class type>
Stack<type>::    ~Stack(){
    delete [] array;
}

////////////////////////////////////////////stack functions ends here ////////////////////////////////////////////////////


////////////////////////////////////////////////////local functions//////////////////////////////////////////////////////

int convert(char b); ///////////////////convert char to integer/////////////////////////////////////////////////////////
int presi(char b); ///////////////////// check presidence /////////////////////////////////////////////////////////////
bool rpn(char*,float&); //////////// evaluate post fix expression////////////////////////////////////////////////
void postfix(char*,char*,Stack<char>&a);////////// convert infix to postfix////////////////////////////////////////////
bool check(char); //////////////////////////// check whether our required operator comes or not //////////////////////
void print(char*);///////////////////////////////print post fix///////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void main()
{
Stack<char> a;
char * expression;
expression=new char[30];
cout<<"Enter Expression";
cin>>expression;

char * temp;
temp=new char[30];
float result=0;
bool flag=true;
int i=0;



//////////////////////////////////////////////function calling////////////////////////////////////////////////////////
postfix(expression,temp,a); // converting post fix to infix

cout<<"PostFix Expression : ";
print(temp); /////////////// printing post fix expression

flag=rpn(temp,result); /////////////////// evaluating post fix expression//////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(flag)
{

cout<<endl;
cout<<"Answer: "<<result<<endl;
}
else
{
cout<<endl;
cout<<"Invalid Expression : "<<endl;
cout<<endl;
}

system("Pause");




}

int convert(char b)
{
switch(b)
{
case '0':
return 0;
break;
case '1':
return 1;
break;

case '2':
return 2;
break;
case '3':
return 3;
break;

case '4':
return 4;
break;

case '5':
return 5;
break;

case '6':
return 6;
break;

case '7':
return 7;
break;

case '8':
return 8;
break;
case '9':
return 9;
break;
}


}
int presi(char b)
{
switch(b)
{
case '|':
return 0;
break;
case '^':
return 1;
break;
case'=':
    return 2;
break;
case '>':
return 3;
break;
case '<':
return 4;
break;
case '-':
return 5;
break;
case '+':
return 6;
break;

case '*':
return 7;
break;
case '/':
return 8;
break;
case '%':
return 9;
break;
case '!':
return 10;
break;
case '#':
return 11;
break;

}
return 0;
}
///////////////////////////////////// convert infix to postfix//////////////////////////////////////////////////////////////////////////
void postfix(char*expression,char*temp,Stack<char>&a)
{
char ch;

int len;
len=strlen(expression);

int it=0;

for(int i=0;i<len;i++)
{
if(expression[i]>=48&&expression[i]<=57)
{
temp[it]=expression[i];
it++;

}
else if(a.isEmpty() && check(expression[i]) )
{
a.push(expression[i]);
//cout<<"done";
}
else if(!a.isEmpty() && check(expression[i]))
{
a.pop(ch);
a.push(ch);

if(expression[i]=='(')
{
a.push(expression[i]);
}
else if(presi(expression[i])<=presi(ch))
{
a.pop(temp[it]);
a.push(expression[i]);
it++;
}
else if(presi(expression[i])>presi(ch))
{
a.push(expression[i]);

}




}
else if(expression[i]==')')
{
a.pop(ch);
temp[it]=ch;
it++;

while(ch!='(')
{
a.pop(ch);
if(ch!='(')
{
temp[it]=ch;
it++;
}
}
}


}

if(!a.isEmpty())
{
while(!a.isEmpty())
{
a.pop(ch);
temp[it]=ch;
it++;
}
}
temp[it]='\0';



}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////// evaluate postfix///////////////////////////////////////////////////////////////////
bool rpn(char*expression,float &temp)

{
Stack<float> a;
float c1;
float c2;
int len=strlen(expression);
for(int i=0;i<len;i++)
{
if(expression[i]>=48&&expression[i]<=57)
{
temp=convert(expression[i]);
a.push(temp);

}
if(expression[i]=='+')
{
a.pop(c1);
a.pop(c2);
temp=c1+c2;
a.push(temp);
}
if(expression[i]=='-')
{
a.pop(c1);
a.pop(c2);
temp=c2-c1;
a.push(temp);
}
if(expression[i]=='*')
{
a.pop(c1);
a.pop(c2);
temp=c1*c2;
a.push(temp);
}
if(expression[i]=='/')
{
a.pop(c1);
a.pop(c2);
temp=c2/c1;
a.push(temp);
}
if(expression[i]=='>')
{
a.pop(c1);
a.pop(c2);
temp=(c2>c1);
a.push(temp);
}
if(expression[i]=='<')
{
a.pop(c1);
a.pop(c2);
temp=c2<c1;
a.push(temp);
}

if(expression[i]=='=')
{
a.pop(c1);
a.pop(c2);
if(c1==c2)
{
a.push(1);
}
else
{
a.push(0);
}
}

if(expression[i]=='|')
{
a.pop(c1);
a.pop(c2);
if((c1==0||c1==1)&&(c2==0||c2==1))
{
if(c1==0 && c2==0)
{
a.push(0);
}
else
{
a.push(1);
}
}
else
{
return false;
break;
}
}
if(expression[i]=='^')
{
a.pop(c1);
a.pop(c2);
if((c1==0||c1==1)&&(c2==0||c2==1))
{
if(c1==1 && c2==1)
{
a.push(1);
}
else
{
a.push(0);
}
}
else
{
return false;
break;
}
}
if(expression[i]=='%')
{
int t1=0;
int t2=0;
int mod=0;

a.pop(c1);
a.pop(c2);
t1=c1;
t2=c2;

mod=t2%t1;

temp=mod;


a.push(temp);
}

if(expression[i]=='!')
{
a.pop(c1);
if(c1==0||c1==1)
{
if(c1==1)
{
a.push(0);
}
else if(c1==0)
{
a.push(1);
}
}
else
{
return false;
break;
}
}
   if(expression[i]=='#')
   {
a.pop(c1);
int aiwi;
aiwi=c1;
int t=0;
t=~aiwi+1;
a.push(t);
}





}
a.pop(temp);
return true;


/*
*/



}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


bool check(char a)
{
if (a=='('||a=='*'||a=='/'||a=='+'||a=='-'||a=='^'||a=='|'||a=='>'||a=='<'||a=='='||a=='%'||a=='#'||a=='!')
{
return true;
}
else
{
return false;
}
}

void print(char*temp)

{
for(int j=0;temp[j]!='\0';j++)
{
if(temp[j]!='(')
{
cout<<temp[j];
}
}

}

Saturday, May 7, 2011

Source code Minesweeper



#include<iostream>
#include<time.h>
#include<ctime>
#include<fstream>;
#include<cstdlib>
using namespace std;

//prototypes of functions
void mines(int a[][8],int size);
void numbers(int array[][8],int size);
void board(char array2[][8],int size);
int axis(int array[][8],char array2[][8],int array3[][8],int array4[][8],int size);
void highscore(int & b);
void help();

//help function
void help(){
cout<<endl;
cout<<"Welcome to Minesweeper Game Made by Dr.Death"<<endl;
cout<<"At any given Time you can press D for Replay or E for Exiting the game"<<endl;
cout<<"1.during play use left and right click option for replay and Exit  "<<endl;
cout<<"2.when u see 0 revealed then u can open its neighboring cell without any risk"<<endl;
cout<<"3.only 10 Flags are available.Flags are your hint that mine is there "<<endl;
cout<<"4.when you will open all the numbers without mine.you will win "<<endl;
cout<<"5.To unflag a flag jump to same cell and press r"<<endl;
}



//Placing mines
void mines(int a[][8],int size){
for(int i=0;i<10;i++)
{
int row=rand()%size;
int col=rand()%size;
if(a[row][col]==9)
{ i--;
}
a[row][col]=9;
}
}

//placing numbers
void numbers(int array[][8],int size){
for(int j=0;j<size;j++){
for(int k=0;k<size;k++){


 if(array[j][k]!=9&&k>0&&k<7){
if(array[j-1][k-1]==9){
array[j][k]++;
}
}
if(array[j][k]!=9&&k>0&&k<7){
if(array[j-1][k]==9){
array[j][k]++;
}
}

if(array[j][k]!=9&&k>0&&k<7){
if(array[j-1][k+1]==9){
array[j][k]++;
}
}

if(array[j][k]!=9&&k>0&&k<7){
if(array[j][k-1]==9){
array[j][k]++;
}

}

if(array[j][k]!=9&&k>0&&k<7){
if(array[j][k+1]==9){
array[j][k]++;
}
}

if(array[j][k]!=9&&k>0&&k<7){
if(array[j+1][k-1]==9){
array[j][k]++;
}
}

if(array[j][k]!=9&&k>0&&k<7){
if(array[j+1][k]==9){
array[j][k]++;
}
}
if(array[j][k]!=9&&k>0&&k<7){
if(array[j+1][k+1]==9){
array[j][k]++;
}
}
}
}
for(j=0;j<size;j++){
for(int k=0;k<size;k++){

if((array[j][k]!=9)&&(k==0)){
if(array[j-1][k]==9){
array[j][k]++;
}
}

if((array[j][k]!=9)&&(k==0)){
if(array[j-1][k+1]==9){
array[j][k]++;
}
}

if((array[j][k]!=9)&&(k==0)){
if(array[j][k+1]==9){
array[j][k]++;
}
}

if((array[j][k]!=9)&&(k==0)){
if(array[j+1][k]==9){
array[j][k]++;
}
}

if((array[j][k]!=9)&&(k==0)){
if(array[j+1][k+1]==9){
array[j][k]++;
}
}




if((array[j][k]!=9)&&(k==7)){
if(array[j-1][k-1]==9){
array[j][k]++;
}
}

if((array[j][k]!=9)&&(k==7)){
if(array[j-1][k]==9){
array[j][k]++;
}
}

if((array[j][k]!=9)&&(k==7)){
if(array[j][k-1]==9){
array[j][k]++;
}
}

if((array[j][k]!=9)&&(k==7)){
if(array[j+1][k-1]==9){
array[j][k]++;
}
}

if((array[j][k]!=9)&&(k==7)){
if(array[j+1][k]==9){
array[j][k]++;
}
}

}
}

}

//setting board
void board(char array2[][8],int size){

char a=178;
for(int m=0;m<size;m++){
for(int j=0;j<size;j++){

array2[m][j]=a;

}
}
}

 //moving in board.this is  the main function
int axis(int array[][8],char array2[][8],int array3[][8],int array4[][8],int size){
int counterf=0;
int total=0; int totalf=0;
int set=0;
char a=178;
char b=179;
int urow;
int ucol;
char o;
char temp;
int count=0;
for(int x=0;x<8;x++){
for(int y=0;y<8;y++){
if(array[x][y]!=9){
totalf=totalf+array[x][y];
}
}
}

int time=0;
int set2;
for(int i=1;i>0;i++)
{
count++;
if(i>0){

time=clock();
if(time/1000>999) // minesweeper has three digit timer
{
time=999999;
}
cout<<"time elasped : "<<time/1000<<" seconds"<<endl;
cout<<"total : "<<total<<endl;
cout<<"Enter row no. : ";
cin>>urow;
cout<<"Enter coloumn no. : ";
cin>>ucol;
cout<<"Enter right click or left click : ";
cin>>o;
urow=urow-1;
ucol=ucol-1;
if(o=='D'||o=='d'){
cout<<"do you really want to restart game(press 1 for yes or any other key for no) ";
cin>>set2;
if(set2==1){
break;
}
if(set2==2){
cout<<" ";
continue;
}
}
if(o=='e'||o=='E'){
cout<<"do you really want to Exit from game(press 1 for yes or anyother key for no) ";
cin>>set2;
if(set2==1){
cout<<"Thanks for Playing Alah Hafiz"<<endl;
system("PAUSE");
return 0;
}
if(set2>=2){
cout<<" ";
continue;
}
}

system("cls");
}
for(int m=0;m<size;m++){
for(int n=0;n<size;n++){
if(m==urow&&n==ucol&&o=='l'&&array[m][n]!=9&&array3[m][n]==0&&array2[m][n]!='f')
{
temp=array[m][n];

if(temp==0){
array2[m][n]=48;
array3[m][n]=1;
}

if(temp==1){
array2[m][n]=49;
array3[m][n]=1;
}

if(temp==2){
array2[m][n]=50;
array3[m][n]=1;
}

if(temp==3){
array2[m][n]=51;
array3[m][n]=1;
}

if(temp==4){
array2[m][n]=52;
array3[m][n]=1;
}

if(temp==5){
array2[m][n]=53;
array3[m][n]=1;
}

if(temp==6){
array2[m][n]=54;
array3[m][n]=1;
}

if(temp==7){
array2[m][n]=55;
array3[m][n]=1;
}

if(temp==8){
array2[m][n]=56;
array3[m][n]=1;

}
total=total+array[m][n];
}
if(m==urow&&n==ucol&&o=='r'&&array3[m][n]==0&&array4[m][n]==0&&counterf<10)
{
array2[m][n]='f';
array4[m][n]=1;
counterf=counterf+1;

}
else if(m==urow&&n==ucol&&o=='r'&&array4[m][n]==1)
{
array2[m][n]=178;
array4[m][n]=0;
counterf=counterf-1;

}

cout<<array2[m][n]<<" "<<" ";

}
cout<<endl<<endl;
}
if(array[urow][ucol]==9&&o=='l'&&array2[urow][ucol]!='f'){
system("cls");
for(m=0;m<8;m++){
for(int n=0;n<8;n++){
if(array[m][n]==9)
{
array2[m][n]='X'; // x is mine
}

cout<<array2[m][n]<<" "<<" ";


}
cout<<endl<<endl;
}

cout<<"you Just hit a mine.ohhh thats sad.better luck next time : "<<endl;

break;
}
if(total==totalf){
int temp4=time/1000;
system("cls");
for(int r=0;r<8;r++){
for(int l=0;l<8;l++){
if(array2[r][l]=='f'|| array[r][l]==9){
array2[r][l]='X';
}
cout<<array2[r][l]<<" "<<" ";
}
cout<<endl<<endl;
}
cout<<"congratulation You win :"<<endl;
highscore(temp4);
break;
}

}
}
void highscore(int & b){
char array[20];
ifstream ifile;
ifile.open("highscore.txt");
ofstream ofile;
ofile.open("highscore.txt");
int a;
while(!ifile.eof()){
ifile>>a;
if(a>b){
ofile<<a; ofile<<" ";
cout<<"Enter name ";
cin.getline(array,20,'\n');
for(int i=0;array[i]!='\0';i++){
ofile<<array[i];
}
}
}
ifile.close();
ofile.close();
}
int main (){
int array[8][8]={0};
int array3[8][8]={0};
int array4[8][8]={0};
char array2[8][8];
int size=8;
int choice;
int choice2;
cout<<"Enter 1 for Help and anyother key to play game "<<endl;
cin>>choice;
if(choice==1){
help();
cout<<endl<<endl;
cout<<"To play game now.Press 3 ";
cin>>choice2;
}
if(choice>=2||choice2==3){

srand(time(0));

mines(array,size);
numbers(array,size);

/*for(int i=0;i<8;i++){
for(int j=0;j<8;j++){
cout<<" "<<array[i][j]<<" ";
}
cout<<endl<<endl;
}
*/
board(array2,size);
axis(array,array2,array3,array4,size);
char o;
cout<<"Do you want to countinue or exit.Enter R for replay or E for exit ";
cin>>o;
switch(o){
case 'r':
case 'R':
{
system("cls");
for(int f=0;f<8;f++){
for(int n=0;n<8;n++){
array[f][n]=0;
array3[f][n]=0;//this array checks whether mine is reveal or unreveal
array4[f][n]=0; // this array checks that whether blocks has some flag or not
array2[f][n]=178;
}
}
mines(array,size);
numbers(array,size);
//board(array,size);
axis(array,array2,array3,array4,size);
break;
}
case 'e':
case 'E':
cout<<"Thanks for Playing.Allah Hafiz"<<endl;
system("PAUSE");
break;

default:
cout<<"Invalid option Entered"<<endl;
break;
}
}
return 0;

}