using namespace std;
int main()
{   int l;
    cout<<"Select level: easy--->1  medium--->2   hard--->3"<<endl;
    cin>>l;
    int zero(char [][3]);
    int fonction(char [][3]);
    char tab[3][3];
    for (int i=0;i<3;i++)
    for(int j=0;j<3;j++)
    tab[i][j]=' ';
    int k;
    do{
         k=fonction(tab);
         zero(tab);
        }
            while(k==2);
        if(k==1)
        cout<<"win";
        if(k==-1)
        cout<<"loose";
        if(k==0)
        cout<<"tie";
        cin>>l;
}//end of main
int zero(char t[][3])
{
    for(int i=0;i<3;i++)
    {
            for(int j=0;j<3;j++)
            {
                               if(t[i][j]==' ')
                               {t[i][j]='O';
                               return 0;}
             }
    }
}
int fonction(char t[][3])
{
    for(int i=0;i<3;i++)
    {
            for(int j=0;j<3;j++)
            {
                    cout<<t[i][j];
                    if(j!=2)
                        cout<<"  "<<"|";


            }
                    cout<<endl;
                    if(i!=2)
                        cout<<"---|---|---"<<endl;
     }                              
     int a,b;
    do{
                  cout<<"donner a et b";
                  cin>>a>>b;

                  }
                        while(t[a][b]!=' ');
    t[a][b]='X';
    int c=0;
    for(int i=0;i<2;i++)
    {
                    if(t[i][i]==t[i+1][i+1])
                    c=1;
                    else c=0;
                    if(c==0)
                    break;
    }
     if(c==1&&t[0][0]!=' ')
     return 1;
     else
     {
             int i=2;
                         for(int j=0;j<2;j++)
                         {
                                         if(t[i][j]==t[i-1][j+1]&&t[i][j]!=' ')
                                         c=1;
                                         else c=0;
                                         if(c==0)
                                         break;
     }

                  if(c==1)
                  return 1;
                  else
                  {for(int i=0;i<3;i++)
                  {
                                  for(int j=0;j<2;j++)
                                  {
                                                  if(t[i][j]==t[i][j+1]&&t[i][j]!=' '&&t[i][j+1]==t[i][j+2])
                                                  {
                                                      c=1;
                                                      break;
                                                  }
                                                  else c=0;
                                                  if(c==0)
                                                  break;
                                  }
                                  if(c==1)
                                      break;
                  }
         if(c==1)
         return 1;
         else                                                                                          
            {
                for(int i=0;i<2;i++)
             {
                 int j=0;
                     if(t[j][i]==t[j+1][i]&&t[j][i]!=' '&&t[j][i]==t[j+2][i])
                                     {
                                     c=1;
                                         break;
                                     }
              }
                     if(c==1)
                     return 1;
                     else
                     {
                         int m=0;
                         for(int i=0;i<3;i++)
                         {
                                         for(int j=0;j<3;j++)
                                         {
                                                         if(t[i][j]==' ')
                                                         m=1;
                                         }
                          }
                     if(m==1)
                     return 2;
                     else return 0;
                     }//accolade de else
                     }//accolade de else
                     }//accolade de else
                     }//accolade de else
}//accolade de la fonction

given that this code is almost c, what have you actually done in order to translate -, the best way to accrue knowledge is to experience it for yourself.

hints ...
namespace ... can be replaced by #include <stdio.h>
cout - can be replaced by printf( .... )

why don't you do a little testing/checking yourself and come back with issues encountered (supplement them with code/output etc)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.