3
已解决
#include<iostream>
#include<bits/stdc++.h>
#include<unistd.h>
#include<windows.h>
#include<conio.h>
#include<tlhelp32.h>
#include<time.h>
#include<stdlib.h>
using namespace std;
#include<iostream>
#include<bits/stdc++.h>
#include<windows.h>
#include<time.h>
#include<unistd.h>
#include<conio.h>
#include<iomanip>
using namespace std;
int b[20][50]={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
void setColor(int color) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
}
void out1(){
for(int i=0;i<=19;i++){
for(int j=0;j<=49;j++){
if(b[i][j]==1){
cout<<'#';
}else if(b[i][j]==0){
cout<<' ';
}else if(b[i][j]==2){
cout<<'@';
}
}
cout<<endl;
}
}
void windows1(){
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO bInfo;
GetConsoleScreenBufferInfo(hOut, &bInfo );
SetConsoleTitle("IWC 2.0"); // 设置窗口的标题
COORD size = {110, 30};//设置窗口大小
SetConsoleScreenBufferSize(hOut,size);
SMALL_RECT rc = {0,0, 110, 30};
SetConsoleWindowInfo(hOut,true ,&rc);
}
void iwc(){
windows1();
//system("color 1F");
setColor(4);
int x=17,y=49;
while(1){
out1();
cout<<endl<<"按0退出"<<endl;
char ch=getch();
if(ch=='s'){
system("cls");
if(b[x+1][y]!=0){
system("cls");
continue;
}
swap(b[x][y],b[x+1][y]);
x+=1;
}else if(ch=='w'){
system("cls");
if(b[x-1][y]!=0){
system("cls");
continue;
}
swap(b[x][y],b[x-1][y]);
b[x][y]=1;
x-=1;
}else if(ch=='a'){
system("cls");
if(b[x][y-1]!=0){
system("cls");
continue;
}
swap(b[x][y],b[x][y-1]);
y-=1;
}else if(ch=='d'){
system("cls");
if(b[x][y+1]!=0){
system("cls");
continue;
}
swap(b[x][y],b[x][y+1]);
y+=1;
}else if(ch=='i'){
b[x-1][y]=0;
system("cls");
}else if(ch=='k'){
b[x+1][y]=0;
system("cls");
}else if(ch=='j'){
b[x][y-1]=0;
system("cls");
}else if(ch=='l'){
b[x][y+1]=0;
system("cls");
}else if(ch=='0'){
return ;
}else{
system("cls");
continue;
}
}
return ;
}
long long wzcnt,srcnt;
char ch;
string wz[105][10005];
void js(){
system("cls");
MessageBox(NULL,"未更新","籍章提示",MB_OKCANCEL);
cout<<"Error!!!"<<endl;
cout<<"出错啦!!!3秒后退出应用。";
sleep(3);
system("cls");
return;
}
void cd(){
cout<<"______________________________________"<<endl;
cout<<"| 籍章(3.0版本) |"<<endl;
cout<<"| |"<<endl;
cout<<"| 公告 |"<<endl;
cout<<"| 目前基础操作正在完善 |"<<endl;
cout<<"| 按下1查看简介、功能 |"<<endl;
cout<<"| 按下2开始编辑文本 |"<<endl;
cout<<"| |"<<endl;
cout<<"| |"<<endl;
cout<<"| |"<<endl;
cout<<"| |"<<endl;
cout<<"| 按0退出 |"<<endl;
cout<<"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"<<endl;
}
void sr(){
srcnt=0;
cout<<"请输入文本,换行输入js0结束"<<endl;
while(true){
srcnt++;
getline(cin,wz[wzcnt][srcnt]);
if(wz[wzcnt][srcnt]=="js0"){
cout<<"已结束"<<endl;
system("cls");
break;
}
wzcnt++;
}
}
void jz(){
MessageBox(NULL,"目前系统为未完成版本","籍章提示",MB_OKCANCEL);
system("pause");
system("cls");
cout<<"二秒后启动";
sleep(2);
system("cls");
for(int i=1;i<=2;i++){
cout<<"正在启动软件.";
sleep(1);
system("cls");
cout<<"正在启动软件..";
sleep(1);
system("cls");
cout<<"正在启动软件...";
sleep(1);
system("cls");
cout<<"正在启动软件....";
sleep(1);
system("cls");
}
while(true){
cd();
ch=getch();
if(ch=='1'){
system("cls");
cout<<" ——籍 章—— "<<endl;
cout<<" 开发者:郑皓予 "<<endl;
cout<<" 这是一个普通的写作工具 "<<endl;
cout<<" 它于2025年7月3日开始开发"<<endl;
cout<<" 目前已是3.0版本 "<<endl;
cout<<" 按Z键继续 "<<endl;
ch=getch();
if(ch='z'){
system("cls");
cd();
ch=getch();
if(ch=='2'){
system("cls");
cout<<"新建文章按Z键"<<",其他键退出"<<endl;
ch=getch();
if(ch=='z'){
if(wzcnt<101){
if(ch=='z'){
system("cls");
wzcnt++;
sr();
}
}
else{
cout<<"文章数已到达上限!!!";
}
}
}
}
}
if(ch=='2'){
system("cls");
cout<<"新建文章按Z键"<<",其他键退出"<<endl;
ch=getch();
if(wzcnt<101){
if(ch=='z'){
system("cls");
wzcnt++;
sr();
}
}
else{
cout<<"文章数已到达上限!!!";
system("cls");
}
}else if(ch=='0'){
return ;
}
else{
continue;
}
system("cls");
}
return ;
}
const int N = 15;//棋盘大小
const char ChessBoardFlag = ' ';
const char flag1 = 'O';
const char flag2 = 'X';
typedef struct Coordinate
{
int x;
int y;
}ChessCoordi;
class FiveChess
{
public:
FiveChess()
{
InitChessBoard();
}
void Play()
{
ChessCoordi Pos1;
ChessCoordi Pos2;
while (1){
int mode = ChoseMode();
while (1){
if (mode == 1){//玩家VS电脑
static size_t count = 1;
PalyerGo(Pos1, 1, flag1);
if (count++ >= 9 && GetWiner(Pos1, 1, flag1))
break;
ComputerGo(Pos2, flag2);
if (count++ >= 10 && GetWiner(Pos2, 0, flag2))
break;
}
else if (mode == 2){//玩家VS玩家
static size_t count = 1;
PalyerGo(Pos1, 1, flag1);
if (count++ >= 9 && GetWiner(Pos1,1, flag1))
break;
PalyerGo(Pos2,2 ,flag2);
if (count++ >= 10 && GetWiner(Pos2,2, flag2))
break;
}else{
return ;
}
}
cout << "再来一局 y or no" << endl;
char chose = 'y';
cin >> chose;
if (chose == 'n')
break;
}
}
void PrintChessBoard()
{
system("cls");
for (size_t i = 0; i < N + 1; ++i)
{
for (size_t j = 0; j < N + 1; ++j)
{
if (i == 0){
if (j != 0)
printf("%d ", j);
else if (j == 0)
printf(" ");
}
else if (j == 0){
if (i != 0)
printf("%2d", i);
}
else{
printf("%c |", ChessBoard[i][j]);
}
}
cout << endl;
cout << " ";
for (size_t i = 1; i < N + 1; ++i){
cout << "---+";
}
cout << endl;
}
}
void InitChessBoard()
{
for (size_t i = 0; i < N + 1; ++i){
for (size_t j = 0; j < N + 1; ++j){
ChessBoard[i][j] = ChessBoardFlag;
}
}
}
protected:
int ChoseMode()
{
system("cls");
InitChessBoard();
cout << "请选择 1.玩家VS电脑 2.玩家VS玩家 3.退出" << endl;
int chose = 0;
cin >> chose;
while (1){
if (chose == 1)
return chose;
else if (chose == 2)
return chose;
else if (chose == 3)
return chose;
else
cout << "对不起 您的输入有误。。" << endl;
}
}
void PalyerGo(ChessCoordi& Pos, int player, char flag)
{
PrintChessBoard();
int x = 0;
int y = 0;
while (1){
cout << "请玩家" << player << "下一步棋" << endl;
cin >> Pos.x >> Pos.y;
if (JudgePos(Pos))
break;
else
cout << "玩家输入错误 ! 请重新输入" << endl;
}
ChessBoard[Pos.x][Pos.y] = flag;
}
void ComputerGo(ChessCoordi& Pos, char flag)
{
PrintChessBoard();
int x = 0;
int y = 0;
while (1){
x = rand() % N + 1;
srand((unsigned int)time(NULL));
y = rand() % N + 1;
srand((unsigned int)time(NULL));//这种方式下生成的x,y一定在棋盘上
if (ChessBoard[x][y] == ChessBoardFlag)
break;
}
Pos.x = x;
Pos.y = y;
ChessBoard[Pos.x][Pos.y] = flag;
}
int GetVictory(ChessCoordi Pos, char flag)//判断是否有赢家
{
int begin = 0;//在**对角线时 作为行坐标的开始 结束
int end = 0;
//**行是否连续5个子
int beginl = 0;//在**对角线时 作为列坐标的开始 结束
int endl = 0;
(Pos.y - 4) > 0 ? begin = Pos.y - 4 : begin = 1;
(Pos.y + 4) < N ? end = Pos.y + 4 : end = N;
for (size_t i = Pos.x, j = begin; j + 4 <= end; ++j)
{
if (flag == ChessBoard[i][j] && flag == ChessBoard[i][j + 1] && \
flag == ChessBoard[i][j + 2] && flag == ChessBoard[i][j + 3] && \
flag == ChessBoard[i][j + 4])
return 1;
}
//**列是否连续5个子
(Pos.x - 4) > 0 ? begin = Pos.x - 4 : begin = 1;
(Pos.x + 4) > N ? end = Pos.x + 4 : end = N;
for (size_t j = Pos.y, i = begin; i + 4 <= end; ++i)
{
if (flag == ChessBoard[i][j] && flag == ChessBoard[i + 1][j] && \
flag == ChessBoard[i + 2][j] && flag == ChessBoard[i + 3][j] && \
flag == ChessBoard[i + 4][j])
return 1;
}
int len = 0;
//**主对角线是否满五个子
(Pos.x > Pos.y) ? len = Pos.y - 1 : len = Pos.x - 1;
if (len > 4)//找落子点到上 左两边的垂直距离较短的地方 如果其大于4 取4 不大于4 取其本身
len = 4;
begin = Pos.x - len;//向上 左移动适当距离找可能的五连子的起始位置
beginl = Pos.y - len;
(Pos.x > Pos.y) ? len = N - Pos.x : len = N - Pos.y;
if (len > 4)
len = 4;
end = Pos.x + len;//向下 右移动适当距离找可能的五连子的终止位置
endl = Pos.y + len;
for (size_t i = begin, j = beginl; i + 4 <= end && j + 4 <= endl; ++i, ++j)
{
if (flag == ChessBoard[i][j] && flag == ChessBoard[i + 1][j + 1] && \
flag == ChessBoard[i + 2][j + 2] && flag == ChessBoard[i + 3][j + 3] && \
flag == ChessBoard[i + 4][j + 4])
return 1;
}
//**副对角线是否满五个子
(Pos.x - 1 > N - Pos.y) ? len = N - Pos.y : Pos.x - 1;
if (len > 4)//找落子点到右 下两边的垂直距离较短的地方 如果其大于4 取4 不大于4 取其本身
len = 4;
begin = Pos.x - len;//向上 右移动适当距离找可能的五连子的起始位置
beginl = Pos.y + len;
(N - Pos.x > Pos.y - 1) ? len = Pos.y - 1 : len = N - Pos.x;
end = Pos.x + len;//向下 左移动适当距离找可能的五连子的最终位置
endl = Pos.y - len;
for (size_t i = begin, j = beginl; i + 4 <= end && j - 4 >= endl; ++i, ++j)
{
if (flag == ChessBoard[i][j] && flag == ChessBoard[i + 1][j - 1] && \
flag == ChessBoard[i + 2][j - 2] && flag == ChessBoard[i + 3][j - 3] && \
flag == ChessBoard[i + 4][j - 4])
return 1;
}
//**棋盘是否已满
for (size_t i = 1; i < N + 1; ++i){
for (size_t j = 1; j < N + 1; ++j){
if (ChessBoard[i][j] == ChessBoardFlag)
return 0;//表示棋盘没满
}
}
//和棋
return -1;
}
bool GetWiner(ChessCoordi& Pos, int player, char flag)//判断是谁赢了
{
int n = 0;
n = GetVictory(Pos, flag);
PrintChessBoard();
if (1 == n){
if (0 == player)
cout << "玩家1获胜" << endl;
else if (1 == player)
cout << "玩家1获胜" << endl;
else
cout << "电脑获胜"<<endl;
return true;
}
else if (-1 == n){
cout << "和棋" << endl;
return true;
}
else{
//还未分出胜负
return false;
}
}
bool JudgePos(const ChessCoordi& Pos)
{
if (Pos.x < N + 1 && Pos.x > 0 && Pos.y < N + 1 && Pos.x > 0\
&& ChessBoard[Pos.x][Pos.y] == ChessBoardFlag)
return true;
return false;
}
private:
char ChessBoard[N + 1][N + 1];
};
//#include"FiveChess.cpp"
void Chess1()
{
//char a[] = "exit";
//for (size_t i = 0; i < sizeof(a) / sizeof(char);++i)
//printf(":%d", a[i]);
FiveChess a;
a.InitChessBoard();
a.PrintChessBoard();
a.Play();
system("pause");
return ;
}
int rec[105];
int turn=0;//0左,2右
bool jumphigher=false;
int manum=1;
int blood=3,maxblood=3;
int nowx=7,nowy=0;
int tim;
struct Button
{
int x,y,color;
const char *name;
int len;
};
void kj(){
MessageBox(NULL,"2.0版本来临","IWXT提示",MB_OKCANCEL);
system("pause");
system("cls");
cout<<"开机中……";
sleep(1);
cout<<"█ █ ";
sleep(1);
cout<<"█ █ ";
sleep(1);
cout<<"█ █ ";
sleep(1);
cout<<"█ █ ";
sleep(1);
cout<<"█ █ ";
sleep(1);
cout<<"█ █ ";
sleep(1);
cout<<"█ █ ";
sleep(1);
cout<<"█ █ ";
sleep(1);
cout<<"█ █ ";
sleep(1);
cout<<"█ █ ";
sleep(1);
system("cls");
}
void zhm(){
system("cls");
cout<<"IWXT 2.0"<<endl<<endl;
cout<<"1.软件管理"<<endl;
cout<<"2.硬件管理"<<endl;
cout<<"3.五子棋"<<endl;
cout<<"4.开始"<<endl;
cout<<"5.IWC"<<endl;
cout<<"6.籍章"<<endl;
}
void rj(){
sleep(1);
system("cls");
cout<<"五子棋 使用率"<<endl;
cout<<100<<"%";
cout<<endl<<"0.返回";
int ch=getch();
if(ch-'0'==0){
return ;
}
}
void yj(){
sleep(1);
system("cls");
cout<<"CPU %"<<90<<endl;
cout<<"C: %"<<26<<endl;
cout<<endl<<"0.返回";
int ch=getch();
if(ch-'0'==0){
return ;
}
}
void yy(){
sleep(1);
system("cls");
cout<<"目前没有应用,后续会更新";
cout<<endl<<"0.返回";
int ch=getch();
if(ch-'0'==0){
return ;
}
}
void ks(){
sleep(1);
system("cls");
cout<<"1.关机";
cout<<endl<<"0.返回";
int ch=getch();
if(ch-'0'==0){
return ;
}else{
abort();
}
}
void windows(){
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO bInfo;
GetConsoleScreenBufferInfo(hOut, &bInfo );
SetConsoleTitle("iwxt 2.0"); // 设置窗口的标题
COORD size = {110, 30};//设置窗口大小
SetConsoleScreenBufferSize(hOut,size);
SMALL_RECT rc = {0,0, 110, 30};
SetConsoleWindowInfo(hOut,true ,&rc);
}
int main(){
windows();
setColor(4);
kj();
cout<<"请输入用户名"<<endl;
string s;
cin>>s;
cout<<"注册成功!"<<endl;
sleep(1);
cout<<"你好 "<<s;
sleep(1);
while(1){
zhm();
int ch;
ch=_getch();
int u=ch-'0';
if(u==1){
rj();
}else if(u==2){
yj();
}else if(u==3){
Chess1();
}else if(u==4){
ks();
}else if(u==5){
iwc();
}else if(u==6){
jz();
}
}
return 0;
}
//|MB_ICONQUESTION