九个c++小游戏源代码和娱乐小程序

· · 休闲·娱乐

九个c++小游戏源代码和娱乐小程序

//狼人杀

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<windows.h>
using namespace std;

struct IDname
{
    int geshu;
    string NAME;
};
IDname jue_se[100];
struct ID
{
    int num;
    bool life;
    string name;
    int know;
    int how;
};
ID player[21];
int n, MY, kill1, kill2;
char a;
bool jieyao = 1, duyao = 1;
int lieren, shouwei = 0;
void init1()
{

    jue_se[1].NAME = "村民 ";
    jue_se[2].NAME = "狼人 ";
    jue_se[3].NAME = "女巫 ";
    jue_se[4].NAME = "预言家 ";
    jue_se[5].NAME = "猎人 ";                         
    jue_se[6].NAME = "守卫 ";
}
void init2(int nn)
{
    switch (nn)
    {
    case 6:
        jue_se[1].geshu = 3;
        jue_se[2].geshu = 2;
        jue_se[3].geshu = 1;
        jue_se[4].geshu = 0;
        jue_se[5].geshu = 0;
        jue_se[6].geshu = 0;
        break;
    case 7:
        jue_se[1].geshu = 3;
        jue_se[2].geshu = 2;
        jue_se[3].geshu = 1;
        jue_se[4].geshu = 1;
        jue_se[5].geshu = 0;
        jue_se[6].geshu = 0;
        break;
    case 8:
        jue_se[1].geshu = 3;2].geshu = 3;
        jue_se[3].geshu = 1;
        jue_se[4].geshu = 1;
        jue_se[5].geshu = 0;
        jue_se[6].geshu = 0;
        break;
    case 9:
        jue_se[1].geshu = 3;
        jue_se[2].geshu = 3;
        jue_se[3].geshu = 1;
        jue_se[4].geshu = 1;
        jue_se[5].geshu = 1;
        jue_se[6].geshu = 0;
        break;
    case 10:
        jue_se[1].geshu = 4;
        jue_se[2].geshu = 3;
        jue_se[3].geshu = 1;
        jue_se[4].geshu = 1;
        jue_se[5].geshu = 1;
        jue_se[6].geshu = 0;
        break;
    case 11:
        jue_se[1].geshu = 4;
        jue_se[2].geshu = 4;
        jue_se[3].geshu = 1;
        jue_se[4].geshu = 1;
        jue_se[5].geshu = 1;
        jue_se[6].geshu = 0;
        break;
    case 12:
        jue_se[1].geshu = 4;
        jue_se[2].geshu = 4;
        jue_se[3].geshu = 1;
        jue_se[4].geshu = 1;
        jue_se[5].geshu = 1;
        jue_se[6].geshu = 1;
        break;
    default:
        cout << "输入错误,再见" << endl;
        exit(0);
        break;
    }
}
int van[10] = { 7,4,6,43,35,1,2,8,20,19 };
void init3(int nn)
{
    srand(time(0));
    Sleep(rand() % 44);
    int x = 10000;
    int t = rand();
    srand(time(NULL));
    int y = van[(rand() % 100 * van[rand() % 10] + t) % 10];
    if (nn <= 6)
        x = abs(x * 6 / y) % 3 + 1;
    else if (nn <= 8)
        x = abs(x * 7 / y) % 4 + 1;
    else if (nn <= 11)
        x = abs(x * 8 / y) % 5 + 1;
    else if (nn <= 14)
        x = abs(x * 9 / y) % 6 + 1;
    do
    {
        if (nn <= 6)
            x = x % 3 + 1;
        else if (nn <= 8)
            x = x % 4 + 1;
        else if (nn <= 11)
            x = x % 5 + 1;
        else if (nn <= 14)
            x = x % 6 + 1;
        if (jue_se[x].geshu > 0)
        {
            player[nn].name = jue_se[x].NAME;
            if (player[nn].name == "猎人 ")
                lieren = nn;
            if (player[nn].name == "守卫 ")
                shouwei = nn;
            player[nn].life = 1;
            player[nn].num = nn;
            player[nn].know = 0;
            jue_se[x].geshu--;
            player[nn].how = 0;
            break;
        }
    } while (jue_se[x].geshu == 0);
}
void printhhh()
{
    int cm = 0;
    int sz = 0;
    for (int i = 1; i <= n; i++)
    {
        if (player[i].life == 0)
            continue;
        else if (player[i].name == "村民 ")
            cm++;
        else if (player[i].name == "女巫 " || player[i].name == "预言家 " || player[i].name == "猎人 " || player[i].name == "守卫 ")
            sz++;
    }
    if (sz == 0 || cm == 0)
        cout << "狼人阵营胜利" << endl;
    else
        cout << "好人阵营胜利" << endl;
    for (int i = 1; i <= n; i++)
    {
        cout << left << setw(3) << player[i].num << ": " << player[i].name << " ";
        if (player[i].life == 0)
            cout << "死亡" << "\t";
        else
            cout << "存活" << "\t";
        if (player[i].how == 0)
            cout << "最终存活 " << endl;
        else if (player[i].how == 1)
            cout << "最终被狼人杀死" << endl;
        else if (player[i].how == 2)
            cout << "最终被投票投死" << endl;
        else if (player[i].how == 3)
            cout << "最终被女巫毒死" << endl;
        else if (player[i].how == 4)
            cout << "最终被猎人射杀" << endl;
    }
    system("pause");
    system("pause");
    system("pause");
}
void print(int day, int ti)
{
    HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
    if (ti == 0)
        SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY);
    else
        SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
    cout << "\t\t\t\t第" << day << "天 ";
    if (ti == 0)
        cout << "白天" << endl;
    else
        cout << "夜晚" << endl;
    cout << "我的位置:" << MY << "号" << endl;
    for (int i = 1; i <= 6; i++)
    {
        cout << player[i].num << "号位 ";
    }
    cout << endl;
    for (int i = 1; i <= 6; i++)
    {
        if (player[i].life == 1)
        {
            if (ti == 0)
                SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY | FOREGROUND_GREEN);
            else
                SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_GREEN);
            cout << "存活 ";
        }
        else
        {
            if (ti == 0)
                SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY | FOREGROUND_RED);
            else
                SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED);
            cout << "已死亡 ";
        }
    }
    if (ti == 0)
        SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY);
    else
        SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
    cout << endl;
    for (int i = 1; i <= 6; i++)
    {
        if (player[i].know == 0)
            cout << "未知 ";
        else if (player[i].know == 1)
        {
            if (player[i].name == "狼人 ")
                cout << "狼人 ";
            else
                cout << "好人 ";
        }
        else if (player[i].know == 2)
            cout << player[i].name << " ";
    }
    cout << endl << endl;
    for (int i = 7; i <= n; i++)
    {
        if (i < 10)
            cout << player[i].num << "号位 ";
        else
            cout << player[i].num << "号位 ";
    }
    cout << endl;
    for (int i = 7; i <= n; i++)
    {
        if (player[i].life == 1)
        {
            if (ti == 0)
                SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY | FOREGROUND_GREEN);
            else
                SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_GREEN);
            cout << "存活 ";
        }
        else
        {
            if (ti == 0)
                SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY | FOREGROUND_RED);
            else
                SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED);
            cout << "已死亡 ";
        }
    }
    if (ti == 0)
        SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY);
    else
        SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
    cout << endl;
    for (int i = 7; i <= n; i++)
    {
        if (player[i].know == 0)
            cout << "未知 ";
        else if (player[i].know == 1)
        {
            if (player[i].name == "狼人 ")
                cout << "狼人 ";
            else
                cout << "好人 ";
        }
        else if (player[i].know == 2)
            cout << player[i].name << " ";
    }
    cout << endl << endl;
}
int shou = 0;
void shoushui(int hhh, int hhhh)
{
    int x;
    Sleep(3000);
    system("cls");
    print(hhh, hhhh);
    cout << "守~卫~请~睁~眼~~~" << endl;
    Sleep(3000);
    system("cls");
    print(hhh, hhhh);
    if (MY == shouwei && player[MY].life == 1)
    {
        cout << "请问你要守护谁?" << endl << "输入:";
        cin >> x;
        while (x == shou || x<1 || x>n || player[x].life == 0)
        {
            cout << "输入错误,请重新输入" << endl << "输入:";
            cin >> x;
        }
        shou = x;
    }
    else if (player[shouwei].life == 1)
    {
        cout << "请问你要守护谁?" << endl;
        Sleep(rand() % 98);
        srand(time(0));
        x = rand() % n + 1;
        while (x == shou || player[x].life == 0)
        {
            Sleep(rand() % 98);
            srand(time(0));
            x = rand() % n + 1;
        }
        shou = x;
    }
    else
    {
        cout << "请问你要守护谁?" << endl;
        Sleep(3000);
        shou = -1;
    }
    Sleep(3000);
    system("cls");
    print(hhh, hhhh);
    cout << "守~卫~请~闭~眼~~~" << endl;
}
struct tou
{
    int xxx;
    int num;
    int toupiaoquan;
};
tou TOU[13];
bool cmp(tou x, tou y)
{
    if (x.xxx == y.xxx)
        return x.num < y.num;
    return x.xxx > y.xxx;
}
bool cmp1(tou x, tou y)
{
    return x.num < y.num;
}
void toupiao(int ddd, int nnn)
{
    //--------1--------
    int x;
    Sleep(2000);
    system("cls");
    print(ddd, nnn);
    cout << "现在大家请投票";
    for (int i = 1; i <= 3; i++)
    {
        cout << ".";
        Sleep(500);
    }
    cout << endl;
    for (int i = 1; i <= n; i++)
    {
        TOU[i].num = i;
        TOU[i].toupiaoquan = 1;
        TOU[i].xxx = 0;
    }
    for (int i = 1; i <= n; i++)
    {
        if (player[i].life == 1)
        {
            Sleep(3000);
            if (i == MY)
            {
                cout << "请投票...(0弃权)" << endl;
                cin >> x;
                while (player[x].life == 0 && x != 0)
                {
                    cin >> x;
                }
                if (x == 0)
                    cout << MY << "号玩家弃权" << endl;
                else
                    cout << MY << "号玩家投给了" << x << "号玩家" << endl;
            }
            else
            {
                srand(time(0));
                if (player[i].name == "狼人 ")
                {
                    x = rand() % (n + 1);
                    while (x != 0 && (player[x].life == 0 || player[x].name == "狼人 " || x == i))
                    {
                        Sleep(rand() % 98);
                        srand(time(0));
                        x = rand() % (n + 1);
                    }
                    if (x == 0)
                        cout << i << "号玩家弃权" << endl;
                    else
                        cout << i << "号玩家投给了" << x << "号玩家" << endl;
                }
                else if (player[i].name == "预言家 ")
                {
                    x = rand() % (n + 1);
                    while (x != 0 && (player[x].life == 0 || player[x].name != "狼人 " || x == i))
                    {
                        Sleep(rand() % 98);
                        srand(time(0));
                        x = rand() % (n + 1);
                    }
                    if (x == 0)
                        cout << i << "号玩家弃权" << endl;
                    else
                        cout << i << "号玩家投给了" << x << "号玩家" << endl;
                }
                else
                {
                    x = rand() % (n + 1);
                    while (x != 0 && (player[x].life == 0 || x == i))
                    {
                        Sleep(rand() % 98);
                        srand(time(0));
                        x = rand() % (n + 1);
                    }
                    if (x == 0)
                        cout << i << "号玩家弃权" << endl;
                    else
                        cout << i << "号玩家投给了" << x << "号玩家" << endl;
                }
            }
            if (x != 0)
                TOU[x].xxx++;
        }
    }
    Sleep(3000);
    sort(TOU + 1, TOU + n + 1, cmp);
    if (TOU[2].xxx != TOU[1].xxx)
    {
        cout << "投票结束," << TOU[1].num << "号投票出局" << endl;
        player[TOU[1].num].life = 0;
        player[TOU[1].num].how = 2;
        Sleep(3000);
        return;
    }
    else
    {
        TOU[1].toupiaoquan = 0;
        TOU[2].toupiaoquan = 0;
        system("cls");
        print(ddd, nnn);
        cout << TOU[1].num << "号," << TOU[2].num << "号";
        int i;
        for (i = 3; i <= n; i++)
        {
            if (TOU[i].xxx == TOU[1].xxx)
            {
                TOU[i].toupiaoquan = 0;
                cout << "," << TOU[i].num << "号";
            }
            else
                break;
        }
        if (i == n + 1)
        {
            for (int i = 1; i <= n; i++)
                TOU[i].toupiaoquan = 1;
        }
        cout << "平票" << endl;
    }
    //--------2--------
    sort(TOU + 1, TOU + n + 1, cmp1);
    cout << "请再次投票";
    for (int i = 1; i <= 3; i++)
    {
        cout << ".";
        Sleep(500);
    }
    cout << endl;
    for (int i = 1; i <= n; i++)
    {
        if (player[i].life == 1 && TOU[i].toupiaoquan == 1)
        {
            Sleep(3000);
            if (i == MY)
            {
                cout << "请投票...(0弃权)" << endl;
                cin >> x;
                while ((player[x].life == 0 || TOU[x].toupiaoquan == 1) && x != 0)
                {
                    cin >> x;
                }
                if (x == 0)
                    cout << MY << "号玩家弃权" << endl;
                else
                    cout << MY << "号玩家投给了" << x << "号玩家" << endl;
            }
            else
            {
                srand(time(0));
                if (player[i].name == "狼人 ")
                {
                    x = rand() % (n + 1);
                    while (x != 0 && (player[x].life == 0 || player[x].name == "狼人 " || x == i || TOU[x].toupiaoquan == 1))
                    {
                        srand(time(0));
                        x = rand() % (n + 1);
                    }
                    if (x == 0)
                        cout << i << "号玩家弃权" << endl;
                    else
                        cout << i << "号玩家投给了" << x << "号玩家" << endl;
                }
                else if (player[i].name == "预言家 ")
                {
                    x = rand() % (n + 1);
                    while (x != 0 && (player[x].life == 0 || player[x].name != "狼人 " || x == i || TOU[x].toupiaoquan == 1))
                    {
                        srand(time(0));
                        x = rand() % (n + 1);
                    }
                    if (x == 0)
                        cout << i << "号玩家弃权" << endl;
                    else
                        cout << i << "号玩家投给了" << x << "号玩家" << endl;
                }
                else
                {
                    x = rand() % (n + 1);
                    while (x != 0 && (player[x].life == 0 || x == i || TOU[x].toupiaoquan == 1))
                    {
                        srand(time(0));
                        x = rand() % (n + 1);
                    }
                    if (x == 0)
                        cout << i << "号玩家弃权" << endl;
                    else
                        cout << i << "号玩家投给了" << x << "号玩家" << endl;
                }
            }
            if (x != 0 && TOU[i].toupiaoquan == 1)
                TOU[x].xxx++;
        }
    }
    Sleep(3000);
    sort(TOU + 1, TOU + n + 1, cmp);
    if (TOU[2].xxx != TOU[1].xxx)
    {
        cout << "投票结束," << TOU[1].num << "号投票出局" << endl;
        player[TOU[1].num].life = 0;
        player[TOU[1].num].how = 2;
        Sleep(3000);
        return;
    }
    else
    {
        TOU[1].toupiaoquan = 0;
        TOU[2].toupiaoquan = 0;
        system("cls");
        print(ddd, nnn);
        cout << TOU[1].num << "号," << TOU[2].num << "号";
        int i;
        for (i = 3; i <= n; i++)
        {
            if (TOU[i].xxx == TOU[1].xxx)
            {
                TOU[i].toupiaoquan = 0;
                cout << "," << TOU[i].num << "号";
            }
            else
                break;
        }
        if (i == n + 1)
        {
            for (int i = 1; i <= n; i++)
                TOU[i].toupiaoquan = 1;
        }
        cout << "平票" << endl;
    }
    //--------3--------
    sort(TOU + 1, TOU + n + 1, cmp1);
    cout << "请再次投票";
    for (int i = 1; i <= 3; i++)
    {
        cout << ".";
        Sleep(500);
    }
    cout << endl;
    for (int i = 1; i <= n; i++)
    {
        if (player[i].life == 1 && TOU[i].toupiaoquan == 1)
        {
            Sleep(3000);
            if (i == MY)
            {
                cout << "请投票...(0弃权)" << endl;
                cin >> x;
                while ((player[x].life == 0 || TOU[x].toupiaoquan == 1) && x != 0)
                {
                    cin >> x;
                }
                if (x == 0)
                    cout << MY << "号玩家弃权" << endl;
                else
                    cout << MY << "号玩家投给了" << x << "号玩家" << endl;
            }
            else
            {
                srand(time(0));
                if (player[i].name == "狼人 ")
                {
                    x = rand() % (n + 1);
                    while (x != 0 && (player[x].life == 0 || player[x].name == "狼人 " || x == i || TOU[x].toupiaoquan == 1))
                    {
                        srand(time(0));
                        x = rand() % (n + 1);
                    }
                    if (x == 0)
                        cout << i << "号玩家弃权" << endl;
                    else
                        cout << i << "号玩家投给了" << x << "号玩家" << endl;
                }
                else if (player[i].name == "预言家 " || player[i].name == "猎人 ")
                {
                    x = rand() % (n + 1);
                    while (x != 0 && (player[x].life == 0 || player[x].name != "狼人 " || x == i || TOU[x].toupiaoquan == 1))
                    {
                        srand(time(0));
                        x = rand() % (n + 1);
                    }
                    if (x == 0)
                        cout << i << "号玩家弃权" << endl;
                    else
                        cout << i << "号玩家投给了" << x << "号玩家" << endl;
                }
                else
                {
                    x = rand() % (n + 1);
                    while (x != 0 && (player[x].life == 0 || x == i || TOU[x].toupiaoquan == 1))
                    {
                        srand(time(0));
                        x = rand() % (n + 1);
                    }
                    if (x == 0)
                        cout << i << "号玩家弃权" << endl;
                    else
                        cout << i << "号玩家投给了" << x << "号玩家" << endl;
                }
            }
            if (x != 0 && TOU[i].toupiaoquan == 1)
                TOU[x].xxx++;
        }
    }
    Sleep(3000);
    sort(TOU + 1, TOU + n + 1, cmp);
    if (TOU[2].xxx != TOU[1].xxx)
    {
        cout << "投票结束," << TOU[1].num << "号投票出局" << endl;
        player[TOU[1].num].life = 0;
        player[TOU[1].num].how = 2;
    }
    else
    {
        cout << "投票结束,无人出局" << endl;
    }
    Sleep(5000);
}
bool game_over()
{
    int pingmin = 0;
    int langren = 0;
    int shenzhi = 0;
    for (int i = 1; i <= n; i++)
    {
        if (player[i].life == 0)
            continue;
        if (player[i].name == "狼人 ")
            langren++;
        else if (player[i].name == "村民 ")
            pingmin++;
        else if (player[i].name == "女巫 " || player[i].name == "预言家 " || player[i].name == "猎人 ")
            shenzhi++;
    }
    if (shenzhi == 0 || langren == 0 || pingmin == 0)
        return 1;
    return 0;
}
void night()
{
    system("cls");
    system("color 0f");
    print(1, 1);
    cout << "天~黑~请~闭~眼~~~" << endl;
    if (n >= 12)
        shoushui(1, 1);
    Sleep(3000);
    system("cls");
    print(1, 1);
    cout << "狼~人~请~睁~眼~~~" << endl;
    if (player[MY].name == "狼人 ")
    {
        Sleep(1000);
        cout << "你的同伴有:";
        for (int i = 1; i <= n; i++)
        {
            if (i == MY)
                continue;
            if (player[i].name == "狼人 ")
            {
                cout << player[i].num << "号 ";
                player[i].know = 2;
            }
        }
        Sleep(3000);
        cout << endl << "请问你们要杀谁:" << endl << "输入:";
        cin >> kill1;
        Sleep(1500);
        system("cls");
        print(1, 1);
        cout << "今晚你们要杀的是" << kill1 << "号玩家" << endl;
    }
    else
    {
        Sleep(4000);
        system("cls");
        print(1, 1);
        cout << "请问你们要杀谁?" << endl;
        do
        {
            Sleep(rand() % 18);
            srand(time(0));
            int x = rand() % n + 1;
            if (player[x].name != "狼人 " && player[x].life == 1)
            {
                kill1 = x;
                break;
            }
        } while (1);
        Sleep(5000);
    }
    Sleep(3000);
    system("cls");
    print(1, 1);
    cout << "狼~人~请~闭~眼~~~" << endl;
    Sleep(2000);
    system("cls");
    print(1, 1);
    cout << "女~巫~请~睁~眼~~~" << endl;
    Sleep(2000);
    system("cls");
    print(1, 1);
    if (player[MY].name == "女巫 " && player[MY].life == 1)
    {
        Sleep(1000);
        if (jieyao == 1)
        {
            cout << "今晚" << kill1 << "号玩家被杀" << endl;
            Sleep(500);
            cout << "请问你要救吗???" << endl << "A. 救 B.不救" << endl << "输入:";
            cin >> a;
            if (a == 'A')
            {
                system("cls");
                print(1, 1);
                cout << "请问你要毒吗???" << endl;
                Sleep(2000);
                system("cls");
                print(1, 1);
                cout << "今晚" << kill1 << "号玩家被你解救" << endl;
                jieyao = 0;
                if (shou != kill1)
                    kill1 = 0;
            }
            else
            {
                if (shou == kill1)
                    kill1 = 0;
                Sleep(2000);
                system("cls");
                print(1, 1);
                cout << "请问你要毒吗???" << endl << "A. 毒 B.不毒" << endl << "输入:";
                cin >> a;
                if (a == 'A')
                {
                    cout << "请问你要毒谁???" << endl << "输入:";
                    cin >> kill2;
                    while (player[kill2].life != 1)
                    {
                        cout << "输入错误,请重新输入:" << endl;
                        cin >> kill2;
                    }
                    duyao = 0;
                }
            }
        }
        else
        {
            if (shou == kill1)
                kill1 = 0;
            Sleep(2000);
            system("cls");
            print(1, 1);
            cout << "请问你要毒吗???" << endl << "A. 毒 B.不毒" << endl << "输入:";
            cin >> a;
            if (a == 'A')
            {
                cout << "请问你要毒谁???" << endl << "输入:";
                cin >> kill2;
                while (player[kill2].life != 1)
                {
                    cout << "输入错误,请重新输入:" << endl;
                    cin >> kill2;
                }
                duyao = 0;
            }
        }
    }
    else
    {
        bool b = 0;
        cout << "请问你是否要用解药???" << endl;
        int FFF = 0, kkkk;
        for (int i = 1; i <= n; i++)
        {
            if (player[i].life == 1 && player[i].name == "村民 ")
                FFF++;
            if (player[i].name == "女巫 ")
                kkkk = i;
        }
        if (jieyao == 1 && player[kkkk].life == 1)
        {
            if (FFF == 1)
            {
                if (shou == kill1)
                    jieyao = 1;
                else
                    jieyao = 0;
                kill1 = 0;
                b = 1;
            }
            else
                for (int i = 1; i <= n; i++)
                {
                    if (player[i].name == "女巫 " && kill1 == i)
                    {
                        kill1 = 0;
                        if (shou == kill1)
                            jieyao = 1;
                        else
                            jieyao = 0;
                        b = 1;
                        break;
                    }
                    else if (player[i].name == "预言家 " && kill1 == i)
                    {
                        kill1 = 0;
                        if (shou == kill1)
                            jieyao = 1;
                        else
                            jieyao = 0;
                        b = 1;
                        break;
                    }
                }
        }
        Sleep(3000);
        if (b == 0 && duyao == 1 && player[kkkk].life == 1)
        {
            system("cls");
            print(1, 1);
            cout << "请问你是否要用毒药???" << endl;
            srand(time(0));
            int x = rand() % 2;
            Sleep(1500);
            cout << "请问你要毒谁???" << endl;
            if (x == 1)
            {
                duyao = 0;
                int y = rand() % n + 1;
                while ((player[y].name == "女巫 " || player[y].name == "预言家 " || y == kill1) || player[y].life == 0)
                    y = rand() % n + 1;
                kill2 = y;
            }
        }
        else
        {
            Sleep(3000);
            system("cls");
            print(1, 1);
            cout << "请问你是否要用毒药???" << endl;
            Sleep(3000);
            cout << "请问你要毒谁???" << endl;
            Sleep(3000);
        }
    }
    Sleep(3000);
    system("cls");
    print(1, 1);
    cout << "女~巫~请~闭~眼~~~" << endl;
    if (n > 6)
    {
        Sleep(3000);
        system("cls");
        print(1, 1);
        cout << "预~言~家~请~睁~眼~~~" << endl;
        if (player[MY].name == "预言家 ")
        {
            Sleep(3000);
            cout << "请问你想查验谁???" << endl << "输入:";
            int x;
            cin >> x;
            player[x].know = 1;
            Sleep(2000);
            system("cls");
            print(1, 1);
            cout << "他的身份是:";
            if (player[x].name == "狼人 ")
                cout << "狼人" << endl;
            else
                cout << "好人" << endl;
            Sleep(3000);
        }
        else
        {
            Sleep(3000);
            cout << "请问你想查验谁???" << endl;
            Sleep(3000);
            system("cls");
            print(1, 1);
            cout << "他的身份是:......";
            Sleep(3000);
        }
        Sleep(3000);
        system("cls");
        print(1, 1);
        cout << "预~言~家~请~闭~眼~~~" << endl;
    }
    Sleep(3000);
    if (kill1 != 0)
        player[kill1].life = 0;
    if (kill2 != 0)
        player[kill2].life = 0;
    player[kill1].how = 1;
    player[kill2].how = 3;
    system("cls");
    system("color F0");
    print(2, 0);
}
void night2(int hhh, int hhhh)
{
    system("cls");
    system("color 0f");
    print(hhh, hhhh);
    cout << "天~黑~请~闭~眼~~~" << endl;
    if (n >= 12)
        shoushui(hhh, hhhh);
    Sleep(3000);
    system("cls");
    print(hhh, hhhh);
    cout << "狼~人~请~睁~眼~~~" << endl;
    if (player[MY].name == "狼人 " && player[MY].life == 1)
    {
        Sleep(3000);
        cout << endl << "请问你们要杀谁:" << endl << "输入:";
        cin >> kill1;
        Sleep(1500);
        system("cls");
        print(hhh, hhhh);
        cout << "今晚你们要杀的是" << kill1 << "号玩家" << endl;
    }
    else
    {
        Sleep(4000);
        system("cls");
        print(hhh, hhhh);
        cout << "请问你们要杀谁?" << endl;
        do
        {
            srand(time(0));
            int x = rand() % n + 1;
            if (player[x].name != "狼人 " && player[x].life == 1)
            {
                kill1 = x;
                break;
            }
        } while (1);
        Sleep(5000);
    }
    Sleep(3000);
    system("cls");
    print(hhh, hhhh);
    cout << "狼~人~请~闭~眼~~~" << endl;
    Sleep(2000);
    system("cls");
    print(hhh, hhhh);
    cout << "女~巫~请~睁~眼~~~" << endl;
    Sleep(2000);
    system("cls");
    print(hhh, hhhh);
    if (player[MY].name == "女巫 " && player[MY].life == 1)
    {
        Sleep(1000);
        if (jieyao == 1)
        {
            cout << "今晚" << kill1 << "号玩家被杀" << endl;
            Sleep(500);
            cout << "请问你要救吗???" << endl << "A. 救 B.不救" << endl << "输入:";
            cin >> a;
            if (a == 'A')
            {
                system("cls");
                print(hhh, hhhh);
                cout << "请问你要毒吗???" << endl;
                Sleep(2000);
                system("cls");
                print(hhh, hhhh);
                cout << "今晚" << kill1 << "号玩家被你解救" << endl;
                jieyao = 0;
                if (shou != kill1)
                    kill1 = 0;
            }
            else
            {
                if (shou == kill1)
                    kill1 = 0;
                Sleep(2000);
                system("cls");
                print(hhh, hhhh);
                cout << "请问你要毒吗???" << endl << "A. 毒 B.不毒" << endl << "输入:";
                cin >> a;
                if (a == 'A')
                {
                    cout << "请问你要毒谁???" << endl << "输入:";
                    cin >> kill2;
                    while (player[kill2].life != 1)
                    {
                        cout << "输入错误,请重新输入:" << endl;
                        cin >> kill2;
                    }
                    duyao = 0;
                }
            }
        }
        else if (duyao == 1)
        {
            if (shou == kill1)
                kill1 = 0;
            Sleep(2000);
            system("cls");
            print(hhh, hhhh);
            cout << "请问你要毒吗???" << endl << "A. 毒 B.不毒" << endl << "输入:";
            cin >> a;
            if (a == 'A')
            {
                cout << "请问你要毒谁???" << endl << "输入:";
                cin >> kill2;
                while (player[kill2].life != 1)
                {
                    cout << "输入错误,请重新输入:" << endl;
                    cin >> kill2;
                }
                duyao = 0;
            }
        }
        else
        {
            Sleep(2000);
            system("cls");
            print(hhh, hhhh);
            cout << "请问你要毒吗???" << endl;
        }
    }
    else
    {
        bool b = 0;
        cout << "请问你是否要用解药???" << endl;
        int FFF = 0, kkkk;
        for (int i = 1; i <= n; i++)
        {
            if (player[i].life == 1 && player[i].name == "村民 ")
                FFF++;
            if (player[i].name == "女巫 ")
                kkkk = i;
        }
        if (jieyao == 1 && player[kkkk].life == 1)
        {
            if (FFF == 1)
            {
                if (shou == kill1)
                    jieyao = 1;
                else
                    jieyao = 0;
                kill1 = 0;
                b = 1;
            }
            else
                for (int i = 1; i <= n; i++)
                {
                    if (player[i].name == "女巫 " && kill1 == i)
                    {
                        kill1 = 0;
                        if (shou == kill1)
                            jieyao = 1;
                        else
                            jieyao = 0;
                        b = 1;
                        break;
                    }
                    else if (player[i].name == "预言家 " && kill1 == i)
                    {
                        kill1 = 0;
                        if (shou == kill1)
                            jieyao = 1;
                        else
                            jieyao = 0;
                        b = 1;
                        break;
                    }
                }
        }
        Sleep(3000);
        if (b == 0 && duyao == 1 && player[kkkk].life == 1)
        {
            system("cls");
            print(hhh, hhhh);
            cout << "请问你是否要用毒药???" << endl;
            srand(time(0));
            int x = rand() % 2;
            Sleep(1500);
            cout << "请问你要毒谁???" << endl;
            if (x == 1)
            {
                duyao = 0;
                int y = rand() % n + 1;
                while ((player[y].name == "女巫 " || player[y].name == "预言家 " || y == kill1) || player[y].life == 0)
                    y = rand() % n + 1;
                kill2 = y;
            }
        }
        else
        {
            Sleep(3000);
            system("cls");
            print(hhh, hhhh);
            cout << "请问你是否要用毒药???" << endl;
            Sleep(3000);
            cout << "请问你要毒谁???" << endl;
            Sleep(3000);
        }
    }
    Sleep(3000);
    system("cls");
    print(hhh, hhhh);
    cout << "女~巫~请~闭~眼~~~" << endl;
    if (n > 6)
    {
        Sleep(3000);
        system("cls");
        print(hhh, hhhh);
        cout << "预~言~家~请~睁~眼~~~" << endl;
        if (player[MY].name == "预言家 " && player[MY].life == 1)
        {
            Sleep(3000);
            cout << "请问你想查验谁???" << endl << "输入:";
            int x;
            cin >> x;
            player[x].know = 1;
            Sleep(2000);
            system("cls");
            print(hhh, hhhh);
            cout << "他的身份是:";
            if (player[x].name == "狼人 ")
                cout << "狼人" << endl;
            else
                cout << "好人" << endl;
            Sleep(3000);
        }
        else
        {
            Sleep(3000);
            cout << "请问你想查验谁???" << endl;
            Sleep(3000);
            system("cls");
            print(hhh, hhhh);
            cout << "他的身份是:......";
            Sleep(3000);
        }
        Sleep(3000);
        system("cls");
        print(hhh, hhhh);
        cout << "预~言~家~请~闭~眼~~~" << endl;
    }
    Sleep(3000);
    if (kill1 != 0)
        player[kill1].life = 0;
    if (kill2 != 0)
        player[kill2].life = 0;
    player[kill1].how = 1;
    player[kill2].how = 3;
    system("cls");
    system("color F0");
    print(hhh + 1, 0);
}
bool lr = 0;
void panduanlieren()
{
    if (lr == 1)
        return;
    if (MY == lieren)
    {
        cout << "请射杀一名玩家" << endl;
        int x;
        cin >> x;
        while (player[x].life != 1)
        {
            cout << "输入错误,请重新输入" << endl;
            cin >> x;
        }
        Sleep(1000);
        cout << lieren << "号猎人发动技能,开枪带走了" << x << "号" << endl;
        player[x].life = 0;
        player[x].how = 4;
    }
    else if (n >= 9)
    {
        srand(time(0));
        int x = rand() % n + 1;
        while (player[x].life != 1)
        {
            x = rand() % n + 1;
        }
        Sleep(1000);
        cout << lieren << "号猎人发动技能,开枪带走了" << x << "号" << endl;
        player[x].life = 0;
        player[x].how = 4;
    }
    lr = 1;
}
void print1()
{
    cout << "天亮了,昨晚";
    if (kill1 != 0 || kill2 != 0)
    {
        cout << kill1 << "号";
        if (kill2 != 0)
        {
            cout << "," << kill2 << "号";
            kill2 = 0;
        }
        cout << "被杀" << endl;
    }
    else
        cout << "是平安夜" << endl;
}
int main()
{
    system("cls");
    cout << " " << "狼人杀online" << endl;
    cout << "请输入人数个数:" << endl;
    cout<<"人数6人以上!"<<endl; 
    scanf("%d", &n);
    cout << "加载时间长,请耐心等待";
    init1();
    init2(n);
    int k = 1;
    do
    {
        srand(time(0));
        init3(k);
        cout << ".";
        Sleep(17);
        k++;
    } while (k <= n);
    system("cls");
    system("color F0");
    cout << "游戏即将开始";
    for (int i = 1; i <= 6; i++)
    {
        cout << ".";
        Sleep(500);
    }
    Sleep(1500);
    cout << endl << endl << "请大家查看身份牌......" << endl;
    Sleep(45);
    srand(time(0));
    MY = rand() % n + 1;
    cout << "您的身份是:" << player[MY].name << endl;
    Sleep(500);
    cout << "在" << player[MY].num << "号位上" << endl;
    system("pause");
    system("cls");
    player[MY].know = 2;
    print(1, 0);
    cout << "即将进入夜晚";
    for (int i = 1; i <= 6; i++)
    {
        cout << ".";
        Sleep(500);
    }
    night();
    print1();
    if (game_over())
    {
        Sleep(1000);
        system("cls");
        cout << "游戏结束" << endl; printhhh();
        return 0;
    }
    if (player[lieren].life == 0 && lr == 0)
    {
        panduanlieren();
    }
    if (game_over())
    {
        Sleep(1000);
        system("cls");
        cout << "游戏结束" << endl; printhhh();
        return 0;
    }
    toupiao(2, 0);
    system("cls");
    print(2, 0);
    if (game_over())
    {
        Sleep(1000);
        system("cls");
        cout << "游戏结束" << endl; printhhh();
        return 0;
    }
    else if (player[lieren].life == 0 && lr == 0)
    {
        panduanlieren();
    }
    cout << "即将进入夜晚";
    for (int i = 1; i <= 6; i++)
    {
        cout << ".";
        Sleep(500);
    }
    night2(2, 1);
    print1();
    if (game_over())
    {
        Sleep(1000);
        system("cls");
        cout << "游戏结束" << endl; printhhh();
        return 0;
    }
    if (player[lieren].life == 0 && lr == 0)
    {
        panduanlieren();
    }
    if (game_over())
    {
        Sleep(1000);
        system("cls");
        cout << "游戏结束" << endl; printhhh();
        return 0;
    }
    toupiao(3, 0);
    system("cls");
    print(3, 0);
    if (game_over())
    {
        Sleep(1000);
        system("cls");
        cout << "游戏结束" << endl; printhhh();
        return 0;
    }
    else if (player[lieren].life == 0 && lr == 0)
    {
        panduanlieren();
    }
    cout << "即将进入夜晚";
    for (int i = 1; i <= 6; i++)
    {
        cout << ".";
        Sleep(500);
    }
    night2(3, 1);
    print1();
    if (game_over())
    {
        Sleep(1000);
        system("cls");
        cout << "游戏结束" << endl; printhhh();
        return 0;
    }
    if (player[lieren].life == 0)
    {
        panduanlieren();
    }
    if (game_over())
    {
        Sleep(1000);
        system("cls");
        cout << "游戏结束" << endl; printhhh();
        return 0;
    }
    toupiao(4, 0);
    system("cls");
    print(4, 0);
    if (game_over())
    {
        Sleep(1000);
        system("cls");
        cout << "游戏结束" << endl; printhhh();
        return 0;
    }
    else if (player[lieren].life == 0 && lr == 0)
    {
        panduanlieren();
    }
    if (game_over())
    {
        Sleep(1000);
        system("cls");
        cout << "游戏结束" << endl; printhhh();
        return 0;
    }
    cout << "即将进入夜晚";
    for (int i = 1; i <= 6; i++)
    {
        cout << ".";
        Sleep(500);
    }
    night2(4, 1);
    print1();
    if (game_over())
    {
        Sleep(1000);
        system("cls");
        cout << "游戏结束" << endl; printhhh();
        return 0;
    }
    if (player[lieren].life == 0)
    {
        panduanlieren();
    }
    if (game_over())
    {
        Sleep(1000);
        system("cls");
        cout << "游戏结束" << endl; printhhh();
        return 0;
    }
    toupiao(5, 0);
    system("cls");
    print(5, 0);
    if (game_over())
    {
        Sleep(1000);
        system("cls");
        cout << "游戏结束" << endl; printhhh();
        return 0;
    }
    else if (player[lieren].life == 0 && lr == 0)
    {
        panduanlieren();
    }
    if (game_over())
    {
        Sleep(1000);
        system("cls");
        cout << "游戏结束" << endl; printhhh();
        return 0;
    }
    cout << "即将进入夜晚";
    for (int i = 1; i <= 6; i++)
    {
        cout << ".";
        Sleep(500);
    }
    night2(5, 1);
    print1();
    if (game_over())
    {
        Sleep(1000);
        system("cls");
        cout << "游戏结束" << endl; printhhh();
        return 0;
    }
    if (player[lieren].life == 0)
    {
        panduanlieren();
    }
    if (game_over())
    {
        Sleep(1000);
        system("cls");
        cout << "游戏结束" << endl; printhhh();
        return 0;
    }
    toupiao(6, 0);
    system("cls");
    print(6, 0);
    if (game_over())
    {
        Sleep(1000);
        system("cls");
        cout << "游戏结束" << endl; printhhh();
        return 0;
    }
    else if (player[lieren].life == 0 && lr == 0)
    {
        panduanlieren();
    }
    if (game_over())
    {
        Sleep(1000);
        system("cls");
        cout << "游戏结束" << endl; printhhh();
        return 0;
    }
    cout << "即将进入夜晚";
    for (int i = 1; i <= 6; i++)
    {
        cout << ".";
        Sleep(500);
    }
    night2(6, 1);
    print1();
    if (game_over())
    {
        Sleep(1000);
        system("cls");
        cout << "游戏结束" << endl; printhhh();
        return 0;
    }
    if (player[lieren].life == 0)
    {
        panduanlieren();
    }
    if (game_over())
    {
        Sleep(1000);
        system("cls");
        cout << "游戏结束" << endl; printhhh();
        return 0;
    }
    toupiao(7, 0);
    system("cls");
    print(7, 0);
    if (game_over())
    {
        Sleep(1000);
        system("cls");
        cout << "游戏结束" << endl; printhhh();
        return 0;
    }
    else if (player[lieren].life == 0 && lr == 0)
    {
        panduanlieren();
    }
    if (game_over())
    {
        Sleep(1000);
        system("cls");
        cout << "游戏结束" << endl; printhhh();
        return 0;
    }
    while (1)
        system("pause");
    return 0;
}

//飞机大战

#include"stdio.h"
#include"windows.h"    //用于获取窗口的句柄与屏幕控制
#include"conio.h"      //用于获取键盘输入的内容
#include"string.h"  
#include"stdlib.h"   
/*两个结构体*/
/*用于存用户信息*/ 
typedef struct usepeople
{
    char name[20];//用户名 
    char mm[20];//密码 
    usepeople *next;
}U;
/*输出历史记录*/ 
struct history
{
    char NAME[20];
    int SCORE;
}s[10];
//定义全局变量
int o;    //保存排行榜分数
char j[20];     //保存排行榜用户名
int h,w;   //定义画面的高和宽 
int p_x,p_y;       // 定义我方飞机的位置
int e_x,e_y;       // 定义敌方飞机的位置 
int b_x,b_y;       //定义子弹的位置 
int score;         //得分
int f;              //定义飞机的状态
int num=1;          //控制排名的数量  (我设置的是8个)     
void gotoxy(int x,int y);              //光标移动到(x,y)位置 
void menu1(U *h,int num);                       //菜单功能   
int color(int c);                       //更改文字颜色
void explation();                    //游戏右侧显示 
void tip();                         //游戏说明
void seescore();                      //分数显示 
void startup();                      //游戏初始化 
void show();                        //显示游戏画面 
void Fly();                         //定义函数来控制子弹和敌人的移动 
void Planefly() ;                   //定义函数来控制飞机的移动和子弹的发射
void gameover(U *h);                  //设计游戏结束界面
U * createpeople(U *h);           //用于注册用户的信息
void create(U *h);                //建立第一个注册信息 
void History(struct history s[],int num); //用于遍历输出挑战者信息
void insert(U *h);            //在结尾加入注册后的玩家账号 
U* search(U *h,char *name);  //用于判断用户的用户名是否正确 
void deletenum(U *h,char name[]);//注销用户信息 
void iregister(U *h);        //注册页面 
void dengru(U *h,int num);   //登入页面 
void log_in(U *h);               //保存用户信息 
void msort(history *a,int n);    //记录冒泡排序 
int color(int c)
{
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), c);        //更改文字颜色
    return 0;
}
//注销用户信息
void deletenum(U *h,char name[])
{
    U *p=h->next;
    while(p&&strcmp(p->name,name)!=0)
    {
        h=p;
        p=p->next;
    }
    if(p)
    {
        h->next=p->next;
        free(p);
    }
}
/*设置光标的位置*/
void gotoxy(int x,int y)
{
    COORD c;
    c.X=x;
    c.Y=y;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),c);
}
/*光标的隐藏*/
void HideCursor()
{
    CONSOLE_CURSOR_INFO cursor_info = {1,0};//第二个值为0表示隐藏光标
    SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}
/*进行冒泡排序*/ 
void msort(history *a,int n)
{

    for(int i=1;i<num;i++)
    {
        for(int f=num;f>i;f--)
        {
            if(s[f].SCORE>s[f-1].SCORE)
            {
                o=a[f].SCORE;
                a[f].SCORE=a[f-1].SCORE;
                a[f-1].SCORE=o;
                strcpy(j,a[f].NAME);
                strcpy(a[f].NAME,a[f-1].NAME);
                strcpy(a[f-1].NAME,j);
            }
        }
    }
}
//用于遍历输出挑战者信息
void History(struct history s[],int num,U* h)
{
    system("cls");
    if(num==1)
    {
        gotoxy(1,1);
        printf("你还没有记录");
    }

    for(int i=1;i<num;i++)   //这里的for是用来逐一输出每一个用户的数据 
    {
        gotoxy(15,3+2*i);
        printf("%d:用户名:%s   ",i,s[i].NAME);
        printf("得分:%d   ",s[i].SCORE);

    }
        gotoxy(1,28);
        printf("请注意最多保存8次记录");
        getch();
        system("cls");
        menu1(h,num);  //看完以后返回开始界面 
} 
//建立第一个注册信息 
void create(U *h)
{
    U *p,*q=h;
    char name[20];
    printf("请输入用户名:\n");
    gotoxy(39,12);
    scanf("%s",name);
    while(strcmp(name,"OVER"))
    {
        p=(U*)malloc(sizeof(U));
        strcpy(p->name,name);
        char mm[20];
        gotoxy(39,13);
        printf("请输入密码:(换行输入OVER结束)\n"); 
        gotoxy(39,14);
        scanf("%s",mm);
        strcpy(p->mm,mm);
        q->next=p;
        q=p;
        gotoxy(39,15);
        scanf("%s",name);
    }
    q->next=NULL;
}

U* search(U *h,char *name)
{
    while(h=h->next,h)
    {if(!strcmp(h->name,name))  return h;}
    return NULL;
}

U * createpeople(U *h)
{
    U *q;
    q=(U*)malloc(sizeof(U));
W:    printf("输入你要注册的用户名:\n");
    scanf("%s",q->name);
    if(search(h,q->name)) {system("cls");printf("该用户名已存在!!!\n");_getch();system("cls");goto W;}
    printf("输入你的密码:\n");
    scanf("%s",q->mm);
    q->next=NULL;
    return q;
}
//在结尾加入注册后的玩家账号 
void insert(U *h)  
{
    U *q,*temp;
    q=createpeople(h);
    while(h=h->next,h){if(h->next==NULL)break;}temp=h;
    q->next=temp->next;
    temp->next=q;
}
/*游戏说明*/
void tip()    
{
    gotoxy(30,5);printf("w向上,s向下,a向左,d向右,按空格射击");
    gotoxy(30,10) ;printf("你击落一架敌机可得1分"); 
    gotoxy(30,15);    printf("如果你被敌机撞上就会死亡");
}                     
void menu1(U *h,int num)                       //菜单功能   
{
    int n;
    gotoxy(37,10);
    printf("飞 机 大 战"); 
    gotoxy(15,20);
    printf("输入数字1:开始游戏") ;
    gotoxy(55,20);
    printf("输入数字2:查看规则");
    gotoxy(15,22);
    printf("输入数字3:查看挑战榜"); 
    gotoxy(55,22);
    printf("输入数字4:退出游戏"); 
    gotoxy(15,24);
    printf("输入数字5:注销账号");
    gotoxy(55,24);
    printf("输入数字6:请你签到"); 
    gotoxy(37,25);
    printf("请输入你的选择:"); 
     scanf("%d",&n);
     switch(n)
     {
         case 1:
             {
                 system("cls"); 
             }break;
        case 2:
            {
                system("cls");
                tip(); 
                printf("\n");
                gotoxy(30,17);
                printf("输入1 ,返回主页");
                int a=0; 
                scanf("%d",&a);
                if(a==1) {system("cls");menu1(h,num);}
            }break;
        case 3:
            {
                 History(s,num,h);    
            }break;
        case 4:
            {
                system("cls");
                printf("你确定要退出游戏吗?\n");
                printf("确定输入1,不确定输入2\n");
                int a=0;
                scanf("%d",&a);
                if(a==1)    exit(0);
                else {system("cls");menu1(h,num);}
            }break;
        case 5:
            {
                char name[20];
                    system("cls");
                    printf("输入要删除在帐号:");
                    scanf("%s",name);
                    deletenum(h,name);
                    printf("输入1 ,返回主页");
                int a=0; 
                scanf("%d",&a);
                if(a==1)
                 {
                   system("cls");
                   if(h->next==NULL)
                    {iregister(h);dengru(h,num);}
                    else dengru(h,num);menu1(h,num);
                 }    
            }break;
        case 6:
            {
                system("cls");log_in(h);
                gotoxy(42,12);printf("请输入任意键继续!!!\n");
                _getch();
                system("cls");
                menu1(h,num);
            }break;
            default:
            {
                gotoxy(37,25);
                printf("请看清楚条件\n");
                _getch();
                system("cls");
                menu1(h,num);
            }break;
     }
} 
void startup()      //游戏初始化 
{
    h=20; //高为20 
    w=50; //宽为50
    score=0; //得分初始化 
    f=1;  //飞机的状态
    p_x=w/2; //飞机x的位置 
    p_y=h-4; //飞机y的位置
    e_x=2+rand()%w-2;
    e_y=0; 
    b_x=p_x;
    b_y=0;
    HideCursor();   //隐藏光标 
}
/*显示游戏画面*/
void show()
{
    int i,j;
    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)
        {
            if(f==0)     break;
            else
            {
            if((i==0)||(j==0)||(i==h-1)||(j==w-1))   printf("+");
            else if((i==p_y)&&(j==p_x))     printf("A");
            else if((i==b_y)&&(j==b_x))       printf("!");
            else if((i==e_y)&&(j==e_x))       printf("@");
            else printf(" ");
            }    
        }
    printf("\n");
    }
    if((p_x==e_x)&&(p_y==e_y))    f--;
}               
/*分数显示  */ 
void seescore(int num)
{
    gotoxy(56,5);printf("w向上,s向下,a向左,d向右,按空格射击");
    gotoxy(56,7);printf("A为您的战机"); 
    gotoxy(56,8);printf("@为敌机");
    gotoxy(2,21);printf("你的得分为%d",score);
    s[num].SCORE=score;
} 
 /*用循环控制敌机的飞行速度*/ 
void Fly()
{
     static int speed=0;
     if(speed<10) speed++;
     if(speed==10)   
     {
         if(e_y<h)   e_y++;
         else { e_y=0;e_x=2+rand()%w-2;}
        speed=0;
     }
}
void b_Fly()
{
     if(b_y>0)     b_y--;//控制子弹的飞行效果 
     if((b_y==e_y)&&(b_x==e_x))      {score++;e_y=0;e_x=2+rand()%w-2;b_y=0;}
}
/*控制飞机的移动*/ 
void Planefly() 
{
    char input;
    if(kbhit()) //kbhit函数是判断是否有输入 
    {
        input=getch(); //将输入的值传入input里面 
        if((input=='w')&&(p_y>1)) //如果按下wsad则相应移动飞机的位置 
        {
            p_y--;
        }
        if((input=='s')&&(p_y<h-2))
        {
            p_y++;
        }
        if((input=='a')&&(p_x>1))
        {
            p_x--;
        }
        if((input=='d')&&(p_x<w-2))
        {
            p_x++;
        }
        if((input==' ')&&(b_y==0))
        {
            b_x=p_x;
            b_y=p_y;
        }
    }
}          
void gameover(U *h)//游戏结束提示 
{
    system("cls");int a;
    gotoxy(39,14);printf("输入1继续打飞机,输入2结束游戏");
    scanf("%d",&a);
    switch(a)
    {
        case 1:{system("cls");}break;
        case 2:{system("cls");exit(0);}break;
        default:{system("cls");printf("请看清楚要求!");_getch();gameover(h);}break;
    }
} 

/*登入与注册*/ 
void iregister(U *h)
{
    char name[20];
    char mm[20];
    gotoxy(51,6);    printf("注册") ;
    gotoxy(39,11);     create(h);//注册
    gotoxy(39,16);
    printf("注册成功!!!(按任意键登入)\n");
    HideCursor();
    _getch();system("cls");
} 
void dengru(U *h,int num)
{
    char name[20];char mm[20];
o:  gotoxy(39,16);
    printf("请输入用户名:\n");
    gotoxy(39,17);
    scanf("%s",name);
    strcpy(s[num].NAME,name);//将用户名存入结构体数组 
    gotoxy(39,18);
    printf("请输入密码:\n");
    gotoxy(39,19);
    scanf("%s",mm);
    if(!search(h,name))  
    {
     system("cls");gotoxy(39,16);printf("没有该用户信息,请先注册!!!(按任意键继续)");
     _getch();system("cls") ;insert(h);system("cls"); goto o; 
    }
    U *temp=search(h,name);//判断密码 
    if(strcmp(temp->mm,mm)) 
    {system("cls");gotoxy(39,17);printf("密码错误,请重新输入!(按任意键继续)");_getch();system("cls") ;dengru(h,num);} 
    else{gotoxy(39,20);printf("登入成功!!!(按任意键开始游戏)");_getch();system("cls");} 
}   
void log_in(U *h) {
    FILE*fp;
    char name[20];char time[20];
    if ((fp = fopen("d:\\informeation storage.txt", "a+")) == NULL) {
        printf("文件不存在,创建成功");
    }
M:    gotoxy(36,9);
    printf("为了为您的账号签到,请再次输入账号\n");
    gotoxy(42,10);
    scanf("%s", name);
    if(!search(h,name))  {gotoxy(42,11);printf("输入错误,请重新输入");_getch();system("cls");goto M;    }
    fputs(name, fp);
    gotoxy(36,11);
    printf("请输入登入的时间\n");
    gotoxy(42,12);
    scanf("%s", time);
    fputs(time, fp);
    fclose(fp);
}
int main ()
{
    system("mode con cols=100 lines=30");  //创建宽100高30的程序界面大小
    U *head=(U*)malloc(sizeof(U)); //建立一个带头的链表 
    iregister(head); L:dengru(head,num);menu1(head,num);startup();//初始化
    while(1)
    {
        gotoxy(0,0);show();seescore(num);
        if(f==0)//判断飞机的状态 
        {
            gameover(head);s[num].SCORE=score;num++;if(num==10) num=1;
            msort(s,num+1);
            goto L;
        }
        b_Fly();Fly();Planefly(); 
    }
    return 0;
 } 

//迷宫


#include <stdio.h>

#include <conio.h>

#include <windows.h>

#include <time.h>

#define Height 31 //迷宫的高度,必须为奇数

#define Width 25 //迷宫的宽度,必须为奇数

#define Wall 1

#define Road 0

#define Start 2

#define End 3

#define Esc 5

#define Up 1

#define Down 2

#define Left 3

#define Right 4


int map[Height+2][Width+2];

void gotoxy(int x,int y) //移动坐标

{

/* typedef struct _COORD {

SHORT X;

SHORT Y;

} COORD, *PCOORD; */

COORD coord;

coord.X=x;

coord.Y=y;

SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), coord );

}

void hidden()//隐藏光标

{

/* typedef void *HANDLE; */

HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);

/* typedef struct _CONSOLE_CURSOR_INFO {

DWORD dwSize;

BOOL bVisible;

} CONSOLE_CURSOR_INFO *PCONSOLE_CURSOR_INFO; */

CONSOLE_CURSOR_INFO cci;

GetConsoleCursorInfo(hOut,&cci);

cci.bVisible = 0;//赋1为显示,赋0为隐藏

SetConsoleCursorInfo(hOut,&cci);

}

void create(int x,int y) //随机生成迷宫

{

int c[4][2] = {0,1,1,0,0,-1,-1,0}; //四个方向

int i,j,t;

//将方向打乱

for(i=0;i<4;i++)

{

j = rand()%4;

t = c[i][0];

c[i][0] = c[j][0];

c[j][0] = t;

t = c[i][1];

c[i][1] = c[j][1];

c[j][1] = t;

}

map[x][y] = Road;

for(i = 0;i < 4;i++)

if(map[x + 2 * c[i][0]][y + 2 * c[i][1]] == Wall)

{

map[x + c[i][0]][y + c[i][1]] = Road;

create(x+ 2 * c[i][0],y + 2 * c[i][1]);

}

}

int get_key() //接收按键

{

char c;

while(c = getch())

{

if(c == 27)

return Esc; //Esc

if(c != -32)

continue;

c = getch();

if(c == 72)

return Up; //上

if(c == 80)

return Down; //下

if(c ==75 )

return Left; //左

if(c == 77)

return Right; //右

}

return 0;

}

void paint(int x,int y) //画迷宫

{

gotoxy(2 * y - 2,x - 1);

switch(map[x][y])

{

case Start:

printf("入");break; //画入口

case End:

printf("出");break; //画出口

case Wall:

printf("※");break; //画墙

case Road:

printf(" ");break; //画路

}

}

void game()

{

int x=2,y=1; //玩家当前位置,刚开始在入口处

int c; //用来接收按键

while(1)

{

gotoxy(2 * y - 2,x - 1);

printf("☆"); //画出玩家当前位置

if(map[x][y] == End) //判断是否到达出口

{

gotoxy(30,24);

printf("到达终点,按任意键结束");

getch();

break;

}

c = get_key();

if(c == Esc)

{

gotoxy(0,24);

break;

}

switch(c)

{

case Up: //向上走

if(map[x-1][y] != Wall)

{

paint(x,y);

x--;

}

break;

case Down: //向下走

if(map[x+1][y] != Wall)

{

paint(x,y);

x++;

}

break;

case Left: //向左走

if(map[x][y-1] != Wall)

{

paint(x,y);

y--;

}

break;

case Right: //向右走

if(map[x][y+1] != Wall)

{

paint(x,y);

y++;

}

break;

}

}

}

int main()

{

int i,j;

srand((unsigned)time(NULL)); //初始化随即种子

hidden(); //隐藏光标

for(i = 0;i <= Height + 1;i++)

for(j = 0;j <= Width + 1;j++)

if(i == 0 || i == Height + 1 || j == 0 || j == Width + 1) //初始化迷宫

map[i][j] = Road;

else

map[i][j] = Wall;

create(2 * (rand() % (Height / 2)+1),2 * (rand() % (Width / 2) + 1)); //从随机一个点开始生成迷宫,该点行列都为偶数

for(i = 0;i <= Height+1;i++) //边界处理

{

map[i][0]=Wall;

map[i][Width+1]=Wall;

}

for(j=0;j<=Width+1;j++) //边界处理

{

map[0][j]=Wall;

map[Height+1][j]=Wall;

}

map[2][1]=Start; //给定入口

map[Height-1][Width]=End; //给定出口

for(i=1;i<=Height;i++)

for(j=1;j<=Width;j++) //画出迷宫

paint(i,j);

game(); //开始游戏

getch();

return 0;

}

//五子棋

#include <cstdio>//输出输入必需 (cout/cin过慢)
#include <windows.h>//用于暂停、清屏等, 非必需 
#include <cstring>
#include <conio.h>
using namespace std;
char board[225];//游戏版定义为char型
const char player_chess[3]= {'@','O','+'}; //玩家用子造型
short var_pos=0;

void out_board(bool round) {

    printf("   A B C D E F G H I J K L M N o\n");//输出列数指示器
    for(short pos=0; pos<225; pos++) {

        if(pos%15==0){
            if(pos!=var_pos)printf("%-2d ",pos/15+1);//输出行数指示器
            else printf("%-2d>",pos/15+1);
        }
        if(pos+1==var_pos) printf("%c>",board[pos]);
        else if(pos==var_pos) printf("%c<",board[pos]);
        else printf("%c ",board[pos]);//输出坐标上的子
        if((pos+1)%15==0) printf("\n");
    }

}
/*
    此函数作用为显示日志,于1.2版本出现.
*/
void scrclr(){    
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD coordScreen = { 0, 0 };   
    SetConsoleCursorPosition( hConsole, coordScreen );
}

void logs() {

    system("cls");
    printf("1.1版本(2022.2.9 存档已丢失):\n");
    printf("    1.列的表示由数字改为小写字母;\n");
    printf("    2.添加了版本信息;\n");
    printf("    3.优化了结束后重新再来时的效果\n");
    printf("    4.优化了排版\n\n");

    printf("1.2版本(2022.2.10 存档已丢失):\n");
    printf("    1.添加更新日志;\n");
    printf("    2.大幅优化源代码(oper()和is_five())并添加注释;\n");
    printf("    3.优化开始时的操作;\n");
    printf("    4.添加大小写转换,现在列数也可以输入大写字母了\n\n");

    printf("1.3版本(2022.2.11 存档已丢失):\n");
    printf("    1.优化了 is_five(),采用了新的算法;\n");
    printf("    2.现在操作输入时的兼容性增加;\n\n");

    printf("Test1.4版本(2022.2.13 16:00):\n");
    printf("    1.把棋盘存储方式改为一维下标,以兼容后面更新;\n");

    printf("1.4版本(2022.2.13 17:10):\n");
    printf("    1.操作方式改为光标;\n");

    printf("1.4.1版本(2022.7.5 14:15):\n");
    printf("    1.小幅优化结束时的卡顿;\n");

    printf("\n"); //结束
}
/*
    此函数作用为显示版本信息.
*/
void Version_information() {
    system("cls");
    printf("作者: Eason95482(又名:Isn\'t)\n");
    printf("版本:1.4.1\n");
    printf("本版本更新时间:2022.7.5 14:15\n\n");
}
/*
    此函数用于开始界面.
*/
void welcome() {
    char in;
    printf("欢迎来到五子棋!\n");
back:
    printf("输入\'s\'以开始游戏,输入\'v\'以查看详细信息,输入\'r\'查看更新日志.");
    in=getchar();
    getchar();
    if(in>='A'&&in<='Z') in+=32;//大小写转换
    switch(in) {
        case 's':
            return;
        case 'v':
            Version_information();
            goto back;

        case 'r':
            logs();
            goto back;

        default:
            printf("未知操作。\n");
            goto back;


    }
}
/*
    此函数作用为清空游戏版,属于重要函数.
    遍历每个坐标,清为 player_chess[2] (放置空)
    游戏板以char形式储存,棋子样子见 player_chess (常量)
*/
void clear_board() {
    memset(board,player_chess[2],225);
}
/*
    此函数控制光标.         
*/
void get_pos(bool round) {
    if(!round) printf("轮到黑方执棋.空格下子:");
    else printf("轮到白方执棋.空格下子:");
    while(1){

        if(_kbhit()){
            char in=_getch();
            if(in=='w') var_pos-=15;
            if(in=='a') var_pos--;
            if(in=='s') var_pos+=15;
            if(in=='d') var_pos++;
            if(in==' ' )return;
            scrclr();
            if(var_pos<0){
                var_pos+=225;
            }
            if(var_pos>=255){
                var_pos-=225;
            }

            out_board(round);
            if(!round) printf("轮到黑方执棋.空格下子:");
            else printf("轮到白方执棋.空格下子:");



            Sleep(1);
        }
    }
}
/*
    玩家操作需要此函数,为核心函数之一.
*/
void oper(bool round) { //0 is Black,1 is White
    turnss:
    get_pos(round);//out用于接收函数状况
    if(board[var_pos]!=
            player_chess[2]) {//判断坐标是否被占
        printf("\n坐标已被占据,请重新输入:");
        goto turnss;
    }
    //将坐标所指格子替换为玩家的棋子.
    board[var_pos]=player_chess[round];
    return;

}

/*
    此函数作用为判断是否有玩家连成5子,为核心函数之一.
    时间复杂度(n为游戏版宽度,默认15) :
    最差 O(n^2 *8) (遍历每一个子查找 n^2,条件判断4*4次,最多深判断1/2个棋盘);
    最优 O(n^2)     (遍历每一个子查找 n^2)
*/
bool is_five(bool round) {
    for(short pos=0; pos<225; pos++) {
        //遍历每个坐标,有子时开始判断.
        if(board[pos]==player_chess[round]) {
            bool row_ok=1,col_ok=1,ru_ld=1,rd_lu=1,flag=1;
            short i=1,row=pos/15,column=pos%15;//i为偏移值
            for(; i<5; i++) {
                if(column>=11||board[pos+i]!=player_chess[round])
                    row_ok=0;
                if(row>=11||board[pos+i*15]!=player_chess[round])
                    col_ok=0;
                if(row>=11&&column>=11||board[pos+i*15+i]!=player_chess[round])
                    rd_lu=0;
                if(row>=11&&column<5||board[pos+i*15-i]!=player_chess[round]) 
                    ru_ld=0;

                if(!row_ok&&!col_ok&&!rd_lu&&!ru_ld) break;
                if(i==4&&(row_ok||col_ok||rd_lu||ru_ld)) return 1;
            }
        }

    }
    return 0;
}
/*
    此函数作用为输出游戏板,为重要函数.
    开始先输出字母(列) 指示器;
    之后遍历每个坐标并直接输出.
*/

/*
    此函数单局游戏主进程,在有玩家连成五子或下完子后返回main(),为核心函数之一.
*/
void game() {
    //初始化
    system("cls");
    clear_board();//清空游戏版
    short chess_num=225; //子数为15*15
    bool round=0;
    out_board(round);//先输出空白游戏版

    while(chess_num/*子数为零时退出*/) {

        oper(round);//玩家操作
        chess_num--;//减子
        scrclr();//清屏
        out_board(round);//输出操作后的游戏版
        if(is_five(round)) break;//如果连成五子则退出
        round=!round;//转换玩家
    }
    //判断结果
    if(chess_num==0) {
        printf("平局!(能平局的都是人才)");
    } else {
        if(round) printf("白方胜!");
        else printf("黑方胜!");
    }

}
int main() {
    welcome();
    char choose;
    while(choose!='q') {
        game();
        printf("\n你想退出吗?输入\"q\"退出,否则再来一局:");
        scanf("%c",&choose);
        getchar();
        if(choose>='A'&&choose<='Z') choose+=32;//大小写转换
    }
    printf("再见!");
    return 0;
}

//俄罗斯方块

#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
#include<time.h>
#include<conio.h>

#define MOD 28
#define SIZE_N 19
#define SIZE_M 12

int cur_x,cur_y;
int score,mark,next,map[SIZE_N][SIZE_M],Gamespeed=300;

int shape[28][6]={
 {0,-1,0,-2,1,0}, {0,1,1,0,2,0}, {-1,0,0,1,0,2}, {0,-1,-1,0,-2,0},
 {0,-1,0,1,-1,0}, {0,1,1,0,-1,0}, {1,0,0,-1,0,1}, {1,0,-1,0,0,-1},
 {-1,1,0,1,1,0}, {0,-1,1,0,1,1}, {-1,0,0,-1,1,-1}, {-1,-1,-1,0,0,1},
 {-1,0,0,1,1,1}, {0,1,1,-1,1,0}, {-1,0,0,1,1,1}, {0,1,1,-1,1,0},
 {-1,0,0,-1,0,-2}, {-1,0,-2,0,0,1}, {0,1,0,2,1,0}, {0,-1,1,0,2,0},
 {0,1,1,0,1,1}, {0,-1,1,0,1,-1}, {-1,0,0,-1,-1,-1}, {-1,0,-1,1,0,1},
 {0,1,0,2,0,3}, {1,0,2,0,3,0}, {0,-1,0,-2,0,-3}, {-1,0,-2,0,-3,0}
};

void gotoxy(int x,int y){
 COORD c;
 c.X=x-1; c.Y=y-1;
 SetConsoleCursorPosition (GetStdHandle(STD_OUTPUT_HANDLE), c);
}
void Gameover(){
 int i,j,flag=0;
 for(j=1;j<SIZE_M-1;j++){
 if(map[1][j]!=0){
  flag=1;break;
 }
 }
 if(flag==1){
 for(i=1;i<SIZE_N-1;i++){
  gotoxy(2,i+1);
  for(j=1;j<SIZE_M-1;j++){
  printf("□");
  }puts("");
 }
 gotoxy(7,9);
 printf("GAME OVER!");
 gotoxy(1,SIZE_N+1);
 exit(0);
 }
}
void ShowMap(int id){
 int i,j;
 gotoxy(1,1);
 if(id!=-1){
 for(i=0;i<SIZE_N;i++){
  for(j=0;j<SIZE_M;j++){
  if(i==0&&j==0 || i==0&&j==SIZE_M-1 || j==0&&i==SIZE_N-1 || j==SIZE_M-1&&i==SIZE_N-1)printf(" ");
  else if(i==0 || i==SIZE_N-1)printf("--");
  else if(j==0 || j==SIZE_M-1)printf("|");
  else if(map[i][j]==2) printf("■");
  else if(i==cur_x+shape[id][0] && j==cur_y+shape[id][1] ||
   i==cur_x+shape[id][2] && j==cur_y+shape[id][3] ||
   i==cur_x+shape[id][4] && j==cur_y+shape[id][5] ||
   i==cur_x && j==cur_y)
   printf("■");
  else if(map[i][j]==0) printf(" ");
  }
  if(i==1)printf(" 下一个 :");
  if(i==11)printf(" 等分 : %d",score);
  if(i==14)printf(" 速度 : %d",score/100+1);
  puts("");
 }
 }
 else {
 mark=1;
 for(i=0;i<SIZE_N;i++){
  for(j=0;j<SIZE_M;j++){
  if(i==0&&j==0 || i==0&&j==SIZE_M-1 || j==0&&i==SIZE_N-1 || j==SIZE_M-1&&i==SIZE_N-1)printf(" ");
  else if(i==0 || i==SIZE_N-1)printf("--");
  else if(j==0 || j==SIZE_M-1)printf("|");
  else if(map[i][j]==2) printf("■");
  else if(map[i][j]==0) printf(" ");
  }
  if(i==1)printf(" next:");
  if(i==11)printf(" score : %d",score);
  if(i==14)printf(" speed : %d",score/100+1);
  puts("");
 }
 }

 gotoxy(30,6); printf(" ");
 for(i=0;i<6;i=i+2){
 gotoxy(30+2*shape[id][i+1],6+shape[id][i]); printf(" ");
 }
 gotoxy(30,6); printf("■");
 for(i=0;i<6;i=i+2){
 gotoxy(30+2*shape[next][i+1],6+shape[next][i]); printf("■");
 }
 Sleep(Gamespeed);
}

void init(int id){
 int i,j;
 memset(map,0,sizeof(map));
 for(i=0;i<SIZE_N;i++){
 for(j=0;j<SIZE_M;j++)
  if(i==SIZE_N-1 || j==0 || j==SIZE_M-1)
  map[i][j]=-1;
 }
 cur_x=0; cur_y=5;
 ShowMap(id);
}

int judge_in(int x,int y,int id){
 int i;
 if(map[x][y]!=0)return 0;
 for(i=0;i<6;i=i+2){
 if(map[ x+shape[id][i] ][ y+shape[id][i+1] ]!=0)return 0;
 }return 1;
}

void fun_score(){
 int i,j,ii,jj;
 for(i=1;i<SIZE_N-1;i++){
 int flag=0;
 for(j=1;j<SIZE_M-1;j++){
  if(map[i][j]!=2){ flag=1;break; }
 }
 if(flag==0){
  int k=3;
  while(k--){
  gotoxy(2,i+1);
  for(ii=1;ii<SIZE_M-1;ii++){
   if(map[i][ii]==2){
   if(k%2==1)printf(" ");
   else printf("■");
   }
  }Sleep(100);
  }
  for(ii=i;ii>1;ii--){
  for(jj=1;jj<SIZE_M-1;jj++) map[ii][jj]=map[ii-1][jj];
  }
  ShowMap(-1);
  score+=10;
  if(score%100==0 && score!=0)Gamespeed-=50;
 }
 }
}

int main(){
 int i,id,set=1;

 srand(time(NULL));
 id=rand()%MOD; id=(id+MOD)%MOD;
 next=rand()%MOD; next=(next+MOD)%MOD;

 init(id);

 while(1){
Here: mark=0;
 if(set==0){
  id=next;
  next=rand()%MOD; next=(next+MOD)%MOD;
  cur_x=0;cur_y=5;
  set=1;
 }

 while(!kbhit()){
  Gameover();
  if(judge_in(cur_x+1,cur_y,id)==1) cur_x++;
  else {
  map[cur_x][cur_y]=2;
  for(i=0;i<6;i=i+2)
   map[ cur_x+shape[id][i] ][ cur_y+shape[id][i+1] ]=2;
  fun_score();
  set=0;
  }
  if(mark!=1)ShowMap(id);
  goto Here;
 }

 char key;
 key=getch();

 if(key==72){
  int tmp=id;
  id++;
  if( id%4==0 && id!=0 )id=id-4;
  if(judge_in(cur_x,cur_y,id)!=1)id=tmp;
 }
 else if(key==80 && judge_in(cur_x+1,cur_y,id)==1)cur_x++;
 else if(key==75 && judge_in(cur_x,cur_y-1,id)==1)cur_y--;
 else if(key==77 && judge_in(cur_x,cur_y+1,id)==1)cur_y++;
 else if(key==27){gotoxy(1,SIZE_N+1);exit(0);}
 }
 getch();
 return 0;
}
//感谢大刁z某的贡献

#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
using namespace std;
char in,ina='a',inb='b',inc='c',ind='d';
long int cfen,cbeg,ctim=120,nowtim=0,maxx;
bool cplay=1,exerc=0;
int main(){
    srand(time(NULL));
    while(1){
        system("cls");
        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY);
        printf("(easy)请选择:\n1.游戏。\n2.设置。");
        in=getch();
        switch(in){
            case '1':{
                cbeg=time(NULL);
                cplay=1;
                cfen=0;
                nowtim=0;
                while(nowtim<ctim){
                    nowtim=time(NULL)-cbeg;
                    if(nowtim>=ctim)break;
                    int word=rand()%4,colo=rand()%4;
                    while(word==colo)colo=rand()%4;
                    system("cls");
                switch(colo){
                    case 0:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);break;//红 
                    case 1:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);break;//绿 
                    case 2:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);break;//黄 
                    case 3:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);break;//粉 
                }
                printf("remaining time:%dS  ",ctim-nowtim);
                if(!exerc)printf("score:%d",cfen);
                printf("\n");
                for(int i=1;i<=5;i++){
                    for(int j=1;j<=20;j++){
                        switch(word){
                            case 0:printf("红");break;
                            case 1:printf("绿");break;
                            case 2:printf("黄");break;
                            case 3:printf("粉");break;
                        }
                    }
                    printf("\n");
                }
                SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
                for(int i=1;i<=20;i++)printf("A");
                printf("\n");
                SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);
                for(int i=1;i<=20;i++)printf("B");
                printf("\n");
                SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);
                for(int i=1;i<=20;i++)printf("C");
                printf("\n");
                SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);
                for(int i=1;i<=20;i++)printf("D");
                printf("\n"); 
                SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN);
                if(nowtim>=ctim)break;
                bool in_ri=1;
                while(in_ri){
                    in=getch();
                    nowtim=time(NULL)-cbeg;
                    if(nowtim>=ctim)break;
                    in_ri=0;
                    if(in==ina){
                      if(word==0)cfen++;
                      else printf("Error:You chose A!\n"),cplay=0;
                  }
                  else if(in==inb){
                      if(word==1)cfen++;
                        else printf("Error:You chose B!\n"),cplay=0;
                  }
                  else if(in==inc){
                      if(word==2)cfen++;
                        else printf("Error:You chose C!\n"),cplay=0;
                  }
                  else if(in==ind){
                      if(word==3)cfen++;
                        else printf("Error:You chose D!\n"),cplay=0;
                  }
                  else in_ri=1;
                }
                if(exerc){
                    if(!cplay)getch();
                    cplay=1;
                }
                if(nowtim>=ctim)break;
                if(!cplay)break;
                }
                nowtim=time(NULL)-cbeg;
                printf("Game Over!\n");
                if(!exerc)printf("Easy:Your score is:%d(%dS).\n",cfen,nowtim);
                maxx=max(maxx,cfen);
                if(!exerc)printf("Your best score is %d.",maxx);
                Sleep(1000);
                getch();
                break;
            }
            case '2':{
                system("cls");
                printf("请输入:\n");
                printf("训练模式(0 or 1)\n");
                cin>>exerc;
                printf("游戏时间\n");
                cin>>ctim;
                printf("代表选项A的键位\n");
                ina=getch();
                printf("代表选项B的键位\n");
                inb=getch();
                printf("代表选项C的键位\n");
                inc=getch();
                printf("代表选项D的键位\n");
                ind=getch();
                if(ina==inb)printf("提示:A选项与B选项的键位重复!\n");
                if(ina==inc)printf("提示:A选项与C选项的键位重复!\n");
                if(ina==ind)printf("提示:A选项与D选项的键位重复!\n");
                if(inb==inc)printf("提示:B选项与C选项的键位重复!\n");
                if(inb==ind)printf("提示:B选项与D选项的键位重复!\n");
                if(inc==ind)printf("提示:C选项与D选项的键位重复!\n");
                getch();
                break;
            }
        }
    }
}

//最帅的man:输出图形

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<windows.h>
using namespace std;
bool po,flag;
void loveling(int love){
    int n;
    while(love){
        if(flag==1){
            n=rand()%60;
            if(n==1)n++;
        }
        else{
            cout<<"输入边长:";
            cin>>n;
            cout<<endl;     
        }
        if(n<=1){
            cout<<"你tm真6"<<endl;
            love--;
            continue;
        }
        int cnt=0;
        n-=2;
        int o=n*2;
        for(int i=1;i<=n+1;i++)cout<<" ";
        cout<<"*"<<endl;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=o/2;j++)cout<<" ";
            cout<<"*";
            for(int p=1;p<=cnt;p++){
                cout<<" ";
            }
            cout<<" *";
            cout<<endl;
            cnt+=2;
            if(o%2==1)o-=2;
            else o--;
        }
        for(int i=1;i<=n+1;i++){
            for(int j=1;j<=o/2;j++)cout<<" ";
            cout<<"*";
            for(int p=1;p<=cnt;p++){
                cout<<" ";
            }
            cout<<" *";
            cout<<endl;
            cnt-=2;
            if(o%2==1)o+=2;
            else o++;
        }
        for(int i=1;i<=n+1;i++)cout<<" ";
        cout<<"*"<<endl;
        love--;
    }
}
void lovezheng(int love){
    int n;
    while(love){
        if(flag==1){
            n=rand()%60;
            if(n==1)n++;
        }
        else{
            cout<<"输入边长:";
            cin>>n;
            cout<<endl; 
        }
        if(n<=1){
            cout<<"你tm真6"<<endl;
            love--;
            continue;
        }
        cout<<"*";
        for(int i=2;i<=n;i++)cout<<" *";
        cout<<endl;
        for(int i=1;i<=n-2;i++){
            cout<<"*";
            for(int j=1;j<=n-2;j++){
                cout<<"  ";
            }
            cout<<" ";
            cout<<"*"<<endl;
        }
        cout<<"*";
        for(int i=2;i<=n;i++)cout<<" *";
        cout<<endl;
        love--;
    }
}
void lovesan(int love){
    int n;
    while(love){
        if(flag==1){
            n=rand()%60;
            if(n==1)n++;
        }
        else{
            cout<<"输入边长:";
            cin>>n;
            cout<<endl; 
        }
        if(n<=1){
            cout<<"你tm真6"<<endl;
            love--;
            continue;
        }
        int cnt=0;
        n-=2;
        int o=n*2;
        for(int i=1;i<=n+1;i++)cout<<" ";
        cout<<"*"<<endl;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=o/2;j++)cout<<" ";
            cout<<"*";
            for(int p=1;p<=cnt;p++){
                cout<<" ";
            }
            cout<<" *";
            cout<<endl;
            cnt+=2;
            if(o%2==1)o-=2;
            else o--;
        }
        for(int i=1;i<=1;i++){
            cout<<"*";
            for(int p=1;p<=cnt+1;p+=2){
                if(p!=cnt+1)cout<<" *";
                else cout<<" ";
            }
            cout<<"*";
            cout<<endl;
        }
        love--;
    }
}
void knby(){
    flag=1;
    int love2=45;
    while(love2--){
        int love=rand()%4;
        if(love==1)loveling(1);else if(love==2)lovezheng(1);else if(love==3)lovesan(1);
    }
    flag=0;
    return;
}
void lgxzd(){
    cout<<"将进谷"<<endl;Sleep(2500);
    cout<<"君不见,高堂明镜悲白发,朝如青丝暮成雪。"<<endl;Sleep(2000);
    cout<<"人生WAWA须尽思,莫使电脑空对题。"<<endl;Sleep(2000);
    cout<<"天生我材没有用,千方百计还RE。"<<endl;Sleep(2000);
    cout<<"AC一点且为乐,会须一刷三百WA。"<<endl;Sleep(2000);
    cout<<"吾团友,牛大佬,"<<endl;Sleep(1100);
    cout<<"将刷题,手莫停!!!"<<endl;Sleep(1100);
    cout<<"与题做一遍,请系统为蒟蒻以测评。"<<endl;Sleep(2000);
    cout<<"天天WAWA不足贵,但愿长眠不复醒!!!"<<endl;Sleep(1750);
    cout<<"古来大佬皆刷题,惟有蒟蒻水犇犇。"<<endl;Sleep(2000);
    cout<<"站长昔时万AC,斗题十千恣欢谑。"<<endl;Sleep(2000);
    cout<<"主人何为言AC?径须沽取对君WA。"<<endl;Sleep(2000);
}
int sleeped(){
    Sleep(1000);
    cout<<"让哥休息一下"<<endl;
    for(int i=1;i<=3;i++){
        cout<<"zzz~"<<endl;
        Sleep(2500);
    }
    cout<<"sb我醒了^_^"<<endl;
    Sleep(500);
    for(int i=1;i<=3;i++){
        cout<<"sb"<<endl;
        Sleep(500);
    }
}
int main(){
    string lx;
    int times,k=0;
    cout<<"此类型执行?次(特殊输0)"<<endl;
    cin>>times;
    if(times==0)cout<<"请输入“看你表演”或“洛谷小诗”"<<endl; 
    else cout<<"请输入类型,此类型执行"<<times<<"次"<<endl;
    while(cin>>lx){
        if(lx=="菱形" or lx=="ling")loveling(times);
        else if(lx=="正方形" or lx=="zhengfang")lovezheng(times);
        else if(lx=="三角形" or lx=="sanjiao")lovesan(times);
        else if(lx=="结束" or lx=="jieshu"){
            cout<<"Bye!";
            return 0;
        }
        else if(lx=="sb" or lx=="SB" or lx=="傻逼"){
            cout<<"滚滚滚,爱玩不玩!"<<endl;
            Sleep(1500);
            cout<<"还玩不玩?(1玩0不玩)"<<endl;
            int adda;
            cin>>adda;
            if(adda==1){
                cout<<"给你个机会,呵呵"<<endl;
                continue;
            }
            else{
                cout<<"呵呵";
                return 0;
            }
        }
        else if(lx=="看你表演" or lx=="knby"){
            cout<<"ok,看我表演!"<<endl;
            Sleep(1500);
            knby();
        }
        else if(lx=="洛谷小诗"  or lx=="lgxs"){
            cout<<"古诗朗诵"<<endl;
            Sleep(1500); 
            lgxzd();
        }
        else{
            cout<<"输错了,再输一遍"<<endl;
            continue; 
        }
        k++;
        if(k%3==0 and k!=0){
            sleeped();
        }
        cout<<"此类型执行?次(特殊输0)"<<endl;
        cin>>times;
        if(times==0)cout<<"请输入“看你表演”或“洛谷小诗”"<<endl; 
        else cout<<"请输入类型,此类型执行"<<times<<"次"<<endl;
        lx="";
    }
    return 0;
}

//娱乐:小黑子快走开,我家格格在下蛋QAQ

#include<bits/stdc++.h>
#include<windows.h>
using namespace std;

int main(){
    string a[32]={"坤坤","只因","rap篮球","小黑子","ikun","是","鸡你太美","漏出只因脚了吧","唱跳","全民制作人","老师","蔡徐坤","坤","坤肉","坤汤","喝","吃","练习时长","两年半","人士","是","kunkun","缺ikun","不ikun","小小小","你没","不打篮球","你不ikun","ikun人士"}; 
    srand(time(NULL));
    while(1){
        int b=rand()%7+4;
        for(int i=1;i<=b;++i){
            cout<<a[rand()%32];
            Sleep(100);
        }
        Sleep(700);
        cout<<"\n";
    }
}