其他分享
首页 > 其他分享> > Clover_BY大佬太巨了(【翻转】游♂戏)

Clover_BY大佬太巨了(【翻转】游♂戏)

作者:互联网

不愧是Clover_BY大佬,Tql

点击查看代码
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <ctime>
#include <windows.h>
using namespace std;

int n, m, x, y, cnt;
char a, b, s, sz[20010][20010];
bool skip = false;

inline char cred(char a, char b)
{
    char c = getchar();
    while(c != a && c != b) c = getchar();
    return c;
}
inline bool credst()
{
    char c = getchar();
    while(c != 'a' && c != 'b') c = getchar();
    return c == 'a' ? true : false;
}

inline int read()
{
    int x = 0; char c; bool f = false;
    while(!isdigit(c = getchar()))
        if(c == '-') f = true;
    do{
        x = (x << 1) + (x << 3) + (c ^ 48);
    }while(isdigit(c = getchar()));
    return f ? -x : x;
}

inline void print()
{
    for(register int i = 1; i <= n; ++i)
    {
        for(register int j = 1; j <= m; ++j)
            printf("%c ", sz[i][j]);
        printf("\n");
    }
    return ;
}

inline void modify(int i, int j, char a, char b)
{
    if(sz[i][j] == a) sz[i][j] = b;
    else sz[i][j] = a;
    return ;
}
inline void touch(int i, int j, char a, char b)
{
    modify(i, j, a, b);
    if(i > 1) modify(i - 1, j, a, b);
    if(i < n) modify(i + 1, j, a, b);
    if(j > 1) modify(i, j - 1, a, b);
    if(j < m) modify(i, j + 1, a, b);
    return ;
}

inline bool examine()
{
    char base = sz[1][1];
    for(register int i = 1; i <= n; ++i)
        for(register int j = 1; j <= m; ++j)
            if(sz[i][j] != base) return false;
    return true;
}

int main()
{
    printf("Please select a mode.(enter the single letter before the option)\n");
    printf("a.I wanna use my own chart!\n");
    printf("b.Create a random chart for me!\n");
    if(credst())
    {
        system("cls");
        printf("Here you could create your own chart.\n"); Sleep(1000);
        printf("First, you should enter the size of the chart here.\n"); Sleep(1000);
        printf("Input the size here (the number of lines first), separated with a single space.\n");
        n = read(); m = read(); system("cls");
        printf("Then, customize the letters you want to add into your charts. Any kind would be welcomed.\n");
        printf("However, this time, a space is a must.\n");
        scanf("%s%s", &a, &b); system("cls");
        printf("Great. Now input the chart here, from left to right, up to down.\n"); Sleep(1000);
        printf("No need to worry that we can't tell the difference from spaces, enters and yours. :-)\n"); Sleep(1000);
        printf("But you should only input the two you have given us.\n");
        for(register int i = 1; i <= n; ++i)
            for(register int j = 1; j <= m; ++j)
                sz[i][j] = cred(a, b);
    }
    else
    {
        system("cls"); srand(time(0));
        printf("Please input the size of chart (the number of lines first), separated with a single space.\n");
        n = read(); m = read(); system("cls");
        printf("Then, customize the letters you want to add into your charts. Any kind would be welcomed.\n");
        printf("However, this time, a space is a must.\n");
        scanf("%s%s", &a, &b); 
        for(register int i = 1; i <= n; ++i)
        {
            for(register int j = 1; j <= m; ++j)
            {
                int x = rand() % 2;
                sz[i][j] = x == 1 ? a : b; 
            }
        }system("cls");
    }
    system("cls");
    printf("Thanks! Now you can enjoy!\n"); Sleep(1000);
    if(!skip)
    {
        printf("But, do you want to read the tutorial first?\n"); Sleep(1000);
        printf("    a.Yes           b.no\n");
        if(!credst()) skip = true;
        else
        {
            system("cls");
            printf("Once you want to make an operation, select a position and let us know the coordinate (the number of line first).\n"); Sleep(2000);
            printf("We will turn the state of that point and every point next to it into the opposite one.\n"); Sleep(2000);
            printf("Your goal is to turn all the letters on the points into all the same!\n"); Sleep(2000);
            printf("If you find that there is no solution to the problem or you want to quit halfway, please enter 114514 1919810, so that we will end the round right away!\n"); Sleep(2000);
            printf("Ready? Press twice to start!\n"); getchar(); getchar();
        }
    }

    system("cls"); cnt = 0; print();
    if(examine())
    {
        printf("Oh, that doesn't need to move a single step.XD\n"); Sleep(1000);
        printf("Wanna try again?\n"); Sleep(1000);
        printf("  a.Yes   b.No\n");
        if(credst()) main();
        else
        {
            printf("Thanks for playing!\n");
            return 0;
        }
    }
    while(1)
    {
        printf("\n");
        x = read(); y = read();
        if(x == 114514 && y == 1919810)
        {
            printf("We are so sorry for bringing you so much unpleasure.\n"); Sleep(1000);
            printf("Wanna try again?\n"); Sleep(1000);
            printf("a.Yes    b.No\n");
            if(credst()) main();
            else
            {
                system("cls");
                printf("Thanks for playing!\n");
                return 0;
            }
        }
        while(x < 1 || x > n || y < 1 || y > n)
        {
            printf("Invalid operation!\n");
            x = read(); y = read();
        }
        touch(x, y, a, b); printf("\nOperation %d : \n", ++cnt); print();
        if(examine())
        {
            printf("Wonderful! You've only got %d moves!\n", cnt); Sleep(1000);
            printf("Wanna try again?\n"); Sleep(1000);
            printf("a.Yes    b.No\n");
            if(credst()) main();
            else
            {
                system("cls");
                printf("Thanks for playing!\n");
                return 0;
            }
        }
    }
    return 0;
}

标签:Clover,include,return,int,char,太巨,printf,大佬,getchar
来源: https://www.cnblogs.com/mizukimiunal/p/16353125.html