数独,迷宫,井字棋游戏三合一

三个游戏打包成一个游戏

代码非常长,耐心观看,先上结果

 

                                                              

 

 

                                                                                                                           

 

 

  源文件代码:

#include<iostream>               //通用输入输出流和其他输入输出流
#include<windows.h>				 //写windows程序需要的重要头文件,此处用于游标和避免闪屏的使用
#include<conio.h>                //通用输入输出库,用户通过按键盘产生的对应操作,比如getch()函数
#include"map1.h"                 //提供地图1
#include"map2.h"                 //提供地图2
#include"map3.h"                 //提供地图3
#include"map4.h"                 //提供地图4
#include"puzzlea.h"              //提供迷宫地图a
#include"puzzleb.h"              //提供迷宫地图b
using namespace std;
void SetPos(COORD a)     //游标
{
    HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleCursorPosition(out, a);
}
void SetPos(int i, int j)
{
    COORD pos = { i, j };
    SetPos(pos);
}
void clearScreen()         //用于清屏并且不会导致闪屏
{
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD coordScreen = { 0, 0 };
    SetConsoleCursorPosition(hConsole, coordScreen);
}
//游戏一
//数独
void rule1()          //制定规则
{
    SetPos(36, 3);
    cout << "数独游戏规则:";
    SetPos(20, 5);
    cout << "1.每一个横/竖列上都要有从1到9的所有数字,不重不漏。";
    SetPos(20, 7);
    cout << "2.每个3 * 3的格自内都要有1到9的所有数字,不重不漏。";
    SetPos(20, 9);
    cout << "玩家先输入行数,用空格隔开后输入列数,最后输入数字,回车确定。";
    SetPos(20, 11);
    cout << "当玩家填满所有格子之后(无论对错),自动生成答案。";
    SetPos(20, 13);
    system("pause");
}
void commence()  //开场动画     
{
    SetPos(50, 4);
    cout << "数    独";
    SetPos(85, 21);
    cout << "制作人:韩谢雨";
    for (int j = 0; j < 100; j++)
    {
        Sleep(20);
        SetPos(j + 3, 10);
        cout << " " << "加载中" << j << "%";
        SetPos(j, 10);
        cout << "■";
    }
    system("cls");
    for (int j = 0; j < 40; j++)
    {
        for (int i = 0; i < 120; i++)
        {
            SetPos(i, j);
            cout << "■";
        }
    }
    system("cls");
}
int start()                //难度选择
{
    SetPos(56, 4);
    cout << "数独游戏";
    SetPos(20, 8);
    cout << "输入1,2,3,4选择难度" << endl;
    SetPos(15, 11);
    cout << "1.简单:通关需要消耗一点点时间";
    SetPos(15, 13);
    cout << "2.普通:通关需要消耗少量的时间";
    SetPos(15, 15);
    cout << "3.困难:通关需要消耗大量的时间";
    SetPos(15, 17);
    cout << "4.地狱:通关需要消耗亿点点时间";
    int n;
    SetPos(15, 21);
    cout << "请输入难度后按回车";
    SetPos(15, 23);
    cin >> n;
    if (n == 1)
    {
        return 1;
    }
    if (n == 2)
    {
        return 2;
    }
    if (n == 3)
    {
        return 3;
    }
    if (n == 4)
    {
        return 4;
    }
}
void printmap1()    //地图1打印                
{
    for (int i = 0; i < 9; i++)
    {
        for (int j = 0; j < 9; j++)
        {
            if (map1[i][j] != 0)
            {
                cout << map1[i][j];
            }
            if (j <= 9)
            {
                cout << " | ";
            }
        }
        cout << "\n";
        if (i < 9)
        {
            cout << "—————————————————" << endl;
        }
    }
    cout << endl;
}
void printmap2()    //地图2打印
{
    for (int i = 0; i < 9; i++)
    {
        for (int j = 0; j < 9; j++)
        {
            if (map2[i][j] != 0)
            {
                cout << map2[i][j];
            }
            if (j <= 9)
            {
                cout << " | ";
            }
        }
        cout << "\n";
        if (i < 9)
        {
            cout << "—————————————————" << endl;
        }
    }
    cout << endl;
}
void printmap3()    //地图3打印
{
    for (int i = 0; i < 9; i++)
    {
        for (int j = 0; j < 9; j++)
        {
            if (map3[i][j] != 0)
            {
                cout << map3[i][j];
            }
            if (j <= 9)
            {
                cout << " | ";
            }
        }
        cout << "\n";
        if (i < 9)
        {
            cout << "—————————————————" << endl;
        }
    }
    cout << endl;
}
void printmap4()    //地图4打印
{
    for (int i = 0; i < 9; i++)
    {
        for (int j = 0; j < 9; j++)
        {
            if (map4[i][j] != 0)
            {
                cout << map4[i][j];
            }
            if (j <= 9)
            {
                cout << " | ";
            }
        }
        cout << "\n";
        if (i < 9)
        {
            cout << "—————————————————" << endl;
        }
    }
    cout << endl;
}
void Game1()
{
    int x, y, z;        //玩家输入位置
    cin >> x >> y >> z;
    while (map1[x - 1][y - 1] != ' ')
    {
        cout << "非法输入" << endl;
        cin >> x >> y >> z;
    }
    map1[x - 1][y - 1] = (char)('0' + z);
}
void Game2()
{
    int x, y, z = 0;    //玩家输入位置
    cin >> x >> y >> z;
    while (map2[x - 1][y - 1] != ' ')
    {
        cout << "非法输入" << endl;
        cin >> x >> y >> z;
    }
    map2[x - 1][y - 1] = (char)('0' + z);
}
void Game3()
{
    int x, y, z = 0;    //玩家输入位置
    cin >> x >> y >> z;
    while (map3[x - 1][y - 1] != ' ')
    {
        cout << "非法输入" << endl;
        cin >> x >> y >> z;
    }
    map3[x - 1][y - 1] = (char)('0' + z);
}
void Game4()
{
    int x, y, z = 0;    //玩家输入位置 
    cin >> x >> y >> z;
    while (map4[x - 1][y - 1] != ' ')
    {
        cout << "非法输入" << endl;
        cin >> x >> y >> z;
    }
    map4[x - 1][y - 1] = (char)('0' + z);
}
void result1()
{
    cout << "标准答案:" << endl;
    for (int i = 0; i < 9; i++)
    {
        for (int j = 0; j < 9; j++)
        {
            if (answer1[i][j] != 0)
            {
                cout << answer1[i][j];
            }
            if (j &l
  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

即.逝

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值