Другие языки программирования и технологии
Visual studio c++ помогите пожалуста!!!
Нужна игра крестики нолики (ток не класичесская) а количество полей задавать самостоятельно(к примеру 10х10,15х10 и т.д) Если у кого есть скиньте пожалуйста проект в Visual studio или borland с++,главное чтоб с++ Cпасибо заранее!!!
#include <iostream>
#include <conio.h>
#include <time.h>
using namespace std;
int main()
{
srand(time(NULL));
bool flag=1;
int v=0;
char mas[ 3 ][ 3 ];
int i,j,u=0;
int x,y;
char ch;
char pl;
for(i=0;i < 3;i++)
for(j=0;j < 3;j++)
mas[ i ][ j ]=NULL;
system("cls");
cout << " | | " << endl;
cout << " " << mas[ 0 ][ 0 ]<<" | " << mas[ 0 ][ 1 ] << " | " << mas[ 0 ][ 2 ] << " " << endl;
cout << " | | " << endl;
cout << "----|----|----" << endl;
cout << " | | " << endl;
cout << " " << mas[ 1 ][ 0 ]<<" | " << mas[ 1 ][ 1 ]<<" | " << mas[ 1 ][ 2 ] << " " << endl;
cout << " | | " << endl;
cout << "----|----|----" << endl;
cout << " | | " << endl;
cout << " " << mas[ 2 ][ 0 ] << " | " << mas[ 2 ][ 1 ]<<" | " << mas[ 2 ][ 2 ] << " " << endl;
cout << " | | " << endl;
while(u<8)
{
if(u%2==0)
{
pl='X';
flag=1;
while(flag)
{
ch = getch();
switch(ch)
{
case '1': if(mas[ 2 ][ 0 ]==0) {mas[ 2 ][ 0 ]=pl; flag=0;} break;
case '2': if(mas[ 2 ][ 1 ]==0) {mas[ 2 ][ 1 ]=pl; flag=0;} break;
case '3': if(mas[ 2 ][ 2 ]==0) {mas[ 2 ][ 2 ]=pl; flag=0;} break;
case '4': if(mas[ 1 ][ 0 ]==0) {mas[ 1 ][ 0 ]=pl; flag=0;} break;
case '5': if(mas[ 1 ][ 1 ]==0) {mas[ 1 ][ 1 ]=pl; flag=0;} break;
case '6': if(mas[ 1 ][ 2 ]==0) {mas[ 1 ][ 2 ]=pl; flag=0;} break;
case '7': if(mas[ 0 ][ 0 ]==0) {mas[ 0 ][ 0 ]=pl; flag=0;} break;
case '8': if(mas[ 0 ][ 1 ]==0) {mas[ 0 ][ 1 ]=pl; flag=0;} break;
case '9': if(mas[ 0 ][ 2 ]==0) {mas[ 0 ][ 2 ]=pl; flag=0;} break;
}
}
system("cls");
}
else //ход компа
{
pl='O';
v=0;
for(i=0;i<3;i++)
{
for(x=0,j=0;j < 3;j++) x+=(int) mas[ i ][ j ];
if(x==264) {cout << endl << "Pobedil igrok"; u=20;}
if(x==158) {cout << endl << "Pobedil komp"; u=20;}
if ((x==176 || x==158) && !v) for(j=0;j<3;j++) if (mas[ i ][ j ]==0) {mas[ i ][ j ]='O'; v=1;}
for(x=0,j=0;j < 3;j++) x+=(int)mas[ j ][ i ];
if(x==264) {cout << endl << "Pobedil igrok"; u=20;}
if(x==158) {cout << endl << "Pobedil komp"; u=20;}
if ((x==176 || x==158) && !v) for(j=0;j<3;j++) if (mas[ j ][ i ]==0) {mas[ j ][ i ]='O';v=1;}
}
for(x=0,j=0;j < 3;j++) x+=(int)mas[ j ][ j ];
if(x==264) {cout << endl << "Pobedil igrok"; u=20;}
if(x==158) {cout << endl << "Pobedil komp"; u=20;}
if ((x==176 || x==158) && !v) for(j=0;j<3;j++) if (mas[ j ][ j ]==0) {mas[ j ][ j ]='O';v=1; }
for(x=0,j=0;j < 3;j++) x+=(int)mas[ j ][ 2-j ];
if(x==264) {cout << endl << "Pobedil igrok"; u=20;}
if(x==158) {cout << endl << "Pobedil komp"; u=20;}
if ((x==176 || x==158) && !v) for(j=0;j<3;j++) if (mas[ j ][ 2-j ]==0) {mas[ j ][ 2-j ]='O'; v=1;}
while(!v)
{
x = rand() % 3;
y = rand() % 3;
if(mas[ x ][ y ]==0)
{
mas[ x ][ y ]= 'O';
v=1;
}
}
cout<< endl;
cout << " | | " << endl;
cout << " " << mas[ 0 ][ 0 ]<<" | " << mas[ 0 ][ 1 ]<<" | " << mas[ 0 ][ 2 ]<<" " << endl;
cout << " | | " << endl;
cout << "----|----|----" << endl;
cout << " | | " << endl;
cout << " " << mas[ 1 ][ 0 ]<<" | " << mas[ 1 ][ 1 ]<<" | " << mas[ 1 ][ 2 ]<<" " << endl;
cout << " | | " << endl;
cout << "----|----|----" << endl;
cout << " | | " << endl;
cout << " " << mas[ 2 ][ 0 ]<<" | " << mas[ 2 ][ 1 ]<<" | " << mas[ 2 ][ 2 ]<<" " << endl;
cout << " | | " << endl;
}
u++;
}
getch();
return 0;
}
#include <conio.h>
#include <time.h>
using namespace std;
int main()
{
srand(time(NULL));
bool flag=1;
int v=0;
char mas[ 3 ][ 3 ];
int i,j,u=0;
int x,y;
char ch;
char pl;
for(i=0;i < 3;i++)
for(j=0;j < 3;j++)
mas[ i ][ j ]=NULL;
system("cls");
cout << " | | " << endl;
cout << " " << mas[ 0 ][ 0 ]<<" | " << mas[ 0 ][ 1 ] << " | " << mas[ 0 ][ 2 ] << " " << endl;
cout << " | | " << endl;
cout << "----|----|----" << endl;
cout << " | | " << endl;
cout << " " << mas[ 1 ][ 0 ]<<" | " << mas[ 1 ][ 1 ]<<" | " << mas[ 1 ][ 2 ] << " " << endl;
cout << " | | " << endl;
cout << "----|----|----" << endl;
cout << " | | " << endl;
cout << " " << mas[ 2 ][ 0 ] << " | " << mas[ 2 ][ 1 ]<<" | " << mas[ 2 ][ 2 ] << " " << endl;
cout << " | | " << endl;
while(u<8)
{
if(u%2==0)
{
pl='X';
flag=1;
while(flag)
{
ch = getch();
switch(ch)
{
case '1': if(mas[ 2 ][ 0 ]==0) {mas[ 2 ][ 0 ]=pl; flag=0;} break;
case '2': if(mas[ 2 ][ 1 ]==0) {mas[ 2 ][ 1 ]=pl; flag=0;} break;
case '3': if(mas[ 2 ][ 2 ]==0) {mas[ 2 ][ 2 ]=pl; flag=0;} break;
case '4': if(mas[ 1 ][ 0 ]==0) {mas[ 1 ][ 0 ]=pl; flag=0;} break;
case '5': if(mas[ 1 ][ 1 ]==0) {mas[ 1 ][ 1 ]=pl; flag=0;} break;
case '6': if(mas[ 1 ][ 2 ]==0) {mas[ 1 ][ 2 ]=pl; flag=0;} break;
case '7': if(mas[ 0 ][ 0 ]==0) {mas[ 0 ][ 0 ]=pl; flag=0;} break;
case '8': if(mas[ 0 ][ 1 ]==0) {mas[ 0 ][ 1 ]=pl; flag=0;} break;
case '9': if(mas[ 0 ][ 2 ]==0) {mas[ 0 ][ 2 ]=pl; flag=0;} break;
}
}
system("cls");
}
else //ход компа
{
pl='O';
v=0;
for(i=0;i<3;i++)
{
for(x=0,j=0;j < 3;j++) x+=(int) mas[ i ][ j ];
if(x==264) {cout << endl << "Pobedil igrok"; u=20;}
if(x==158) {cout << endl << "Pobedil komp"; u=20;}
if ((x==176 || x==158) && !v) for(j=0;j<3;j++) if (mas[ i ][ j ]==0) {mas[ i ][ j ]='O'; v=1;}
for(x=0,j=0;j < 3;j++) x+=(int)mas[ j ][ i ];
if(x==264) {cout << endl << "Pobedil igrok"; u=20;}
if(x==158) {cout << endl << "Pobedil komp"; u=20;}
if ((x==176 || x==158) && !v) for(j=0;j<3;j++) if (mas[ j ][ i ]==0) {mas[ j ][ i ]='O';v=1;}
}
for(x=0,j=0;j < 3;j++) x+=(int)mas[ j ][ j ];
if(x==264) {cout << endl << "Pobedil igrok"; u=20;}
if(x==158) {cout << endl << "Pobedil komp"; u=20;}
if ((x==176 || x==158) && !v) for(j=0;j<3;j++) if (mas[ j ][ j ]==0) {mas[ j ][ j ]='O';v=1; }
for(x=0,j=0;j < 3;j++) x+=(int)mas[ j ][ 2-j ];
if(x==264) {cout << endl << "Pobedil igrok"; u=20;}
if(x==158) {cout << endl << "Pobedil komp"; u=20;}
if ((x==176 || x==158) && !v) for(j=0;j<3;j++) if (mas[ j ][ 2-j ]==0) {mas[ j ][ 2-j ]='O'; v=1;}
while(!v)
{
x = rand() % 3;
y = rand() % 3;
if(mas[ x ][ y ]==0)
{
mas[ x ][ y ]= 'O';
v=1;
}
}
cout<< endl;
cout << " | | " << endl;
cout << " " << mas[ 0 ][ 0 ]<<" | " << mas[ 0 ][ 1 ]<<" | " << mas[ 0 ][ 2 ]<<" " << endl;
cout << " | | " << endl;
cout << "----|----|----" << endl;
cout << " | | " << endl;
cout << " " << mas[ 1 ][ 0 ]<<" | " << mas[ 1 ][ 1 ]<<" | " << mas[ 1 ][ 2 ]<<" " << endl;
cout << " | | " << endl;
cout << "----|----|----" << endl;
cout << " | | " << endl;
cout << " " << mas[ 2 ][ 0 ]<<" | " << mas[ 2 ][ 1 ]<<" | " << mas[ 2 ][ 2 ]<<" " << endl;
cout << " | | " << endl;
}
u++;
}
getch();
return 0;
}
Похожие вопросы
- Visual Studio C++, ошибка : "не удается найти указанный файл"
- Помогите решить задачу в visual studio c++
- помогите решить задачи оператор switch решение нужно visual studio (C)
- Возможно ли из программы, написанной в VISUAL STUDIO c++ извлечь exeшник так, чтобы он запускался абсолютно везде?
- Задание для visual studio(c++)
- Нужно создать консольное приложение на языке С++ в visual studio 2017. Помогите, прошу !
- Здравствуйте товарищи программисты хотел спросить. VIsual studio 2022 или Visual Studio Code
- Visual Studio 2010 C++: Как создать оконное приложение?
- как в Microsoft Visual Studio 2010 в C# в системе счисления, перевести в десятеричную? Как дополнить код? Помогите плиз
- помогите сделать задание в Microsoft Visual Studio