/ Vijos / 讨论 / 游戏 /

2048 ++ game

一个好玩的2048 (有多种模式)

| 本2048游戏纯属玩乐,请勿与真实版本2048相提并论! |
| 版本号:2.0 |
| 游戏规则: |
| 0 经典模式:合并相同的数字,你的目标是2048! |
| 1 小三传奇:原创游戏模式,初始数字可能是1、2、3,你需要合并1、2得到3,然后将3俩俩合并,你的目标是1536! |
| 2 只有2模式:同经典模式,只是不会出现4,只出现2,你的目标是4096! |
| 3 斐波那契数列模式:只会出现1,斐波那契数列为1、1、2、3、5、8、13、21......数列中相邻的两个数字可以合并,你的目标是合并出4181! |
| 4 任意合并模式:任何数字都可以合并,刷分上段好帮手(当我没说)......纯属娱乐 |
| 5 时间限定模式(正在调试):限定一个时间,练习手速和反应,以及快速计算能力,联赛选手赛前训练必备!参考值:1分20秒 512;2分20秒 1024; 3分55秒2048 |

| |


|硬件要求: |
|运行内存:3.5GB(可以保证1秒两下不卡顿) 硬盘内存:156.6MB |
|确保你已经安装了Devcpp或者其他4.0以上的支持所有保留字的C++编译器 |

|方法:把里面的main.cpp打开,编译运行(切勿篡改其他文件!),目前暂不支持exe运行 |

/*
    Name:2048 Multifunctional Game Version 2.0 
    Copyright: Copyright G.W & Z is all rights reserved!
    Author: 4096 Team From 192.168.41.243 
    Date: 27/07/17 00:15
    Description: New game mode! You can enjoy the trainment for professional league competitions! Have a good time!
*/  

//#ifndef __2048H.H
//#define __2048H.H

#include<bits/stdc++.h>
#include<windows.h>
#include<time.h>
#include <conio.h>
#define rnd(n) (int)(rand()%n+1)
#define R  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED)
#define Ob  Rb
#define Rb  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_RED|BACKGROUND_INTENSITY)
#define W  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN)
#define Wb  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_RED|BACKGROUND_BLUE|BACKGROUND_GREEN|BACKGROUND_INTENSITY)
#define Wb2  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_RED|BACKGROUND_BLUE|BACKGROUND_GREEN)
#define B  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_BLUE)
#define Bb  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_BLUE)
#define G  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN)
#define Gb  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_GREEN|BACKGROUND_INTENSITY)
#define Y  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN)
#define Yb  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_INTENSITY)
#define S  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN|FOREGROUND_BLUE)
#define Sb  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_GREEN|BACKGROUND_BLUE|BACKGROUND_INTENSITY)
#define P  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_BLUE|FOREGROUND_RED)
#define Pb  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_BLUE|BACKGROUND_RED|BACKGROUND_INTENSITY)
using namespace std;
// #endif

#define __STD 1
#define __ONLY2 1
#define __LITTLE3 1
#define __MS 1
#define __FEB 1
#define __LIMIT 0

/* ERROR ___*/
#define __ERROR_0 "This is developing.\n\
Please waiting for it.\nThanks for using this program."
#define __ERROR_1 ""

int a[30][30]={0};
bool kkk;
int n,kl;
int sc=0;
int lg = rnd(2);//LTL used
void outp();
void r();
void d();
bool check_fi(int lol,int olo)  //  check Fibonacci Number
{
    if(lol > olo)   swap(lol,olo);
    if(lol == olo && lol == 1)  return 1;
    if(lol == 1 && olo == 2)    return 1;
    if(olo < (lol * 2) && olo > lol)    return 1;
    return 0;
}   
void outp()
{
    system("cls");
    system("color 70");
    cout<<"score:"<<sc<<endl;
    for (int i=1;i<=n;i++)
    {
        Yb,cout<<'|';for (int j=1;j<=n;j++) Yb,printf("------|");cout<<endl;
        Yb,cout<<'|';for (int j=1;j<=n;j++) if (a[i][j]==0) Wb2,printf("      ",a[i][j]),Yb,cout<<'|';
                                else if (a[i][j]>8) Rb,printf("%4d  ",a[i][j]),Yb,cout<<'|';  
                                    else if(a[i][j] > 4) Ob,printf("%4d  ",a[i][j]),Yb,cout<<'|'; 
                                        else if (a[i][j]>2) Yb,printf("%4d  ",a[i][j]),Yb,cout<<'|'; 
                                            else Wb,printf("%4d  ",a[i][j]),Yb,cout<<'|';cout<<endl;
        Yb,cout<<'|';for (int j=1;j<=n;j++) if (a[i][j]==0) Wb2,printf("      "),Yb,cout<<'|';
                                else if (a[i][j]>8) Rb,printf("      "),Yb,cout<<'|';
                                    else if(a[i][j] > 4) Ob,printf("      "),Yb,cout<<'|'; 
                                         else if (a[i][j]>2) Yb,printf("      "),Yb,cout<<'|'; 
                                            else Wb,printf("      "),Yb,cout<<'|';cout<<endl;
    }
    Yb,cout<<'|';for (int j=1;j<=n;j++) Yb,printf("------|");cout<<endl;
}
void r()
{
    //if (kl==0) cout<<"You out! score:"<<sc,Sleep(2000),exit(0);
    int g=rnd(kl--);
    for (int i=1;i<=n;i++)
        for (int j=1;j<=n;j++)
        {
            if (a[i][j]==16) {}//cout<<"You are win!";//,Sleep(2000),exit(0);
            if (a[i][j]==0){
                g--;
                if (!g) if (rnd(8)==5) a[i][j]=4; else a[i][j]=2;
            }  
        }
}
void ltl_output()       //output of LITTLE THREE LEGEND
{
    //if (kl==0) cout<<"You out! score:"<<sc,Sleep(2000),exit(0);
    int g=rnd(kl--);
    for (int i=1;i<=n;i++)
        for (int j=1;j<=n;j++)
        {
            if (a[i][j]==16) cout<<"You are win!";//,Sleep(2000),exit(0);
            if (a[i][j]==0){
                g--;
                if (!g) if (rnd(8)==7) a[i][j]=3; else{ a[i][j]=(lg*2)%3; lg = (lg*2)%3;}
            }  
        }
}
void addd()
{
    int xxx = rnd(n),yyy = rnd(n);
    while(a[xxx][yyy])
    {
        xxx = rnd(n);
        yyy = rnd(n);
    }
    a[xxx][yyy] = 2 * rnd(2);
}
void fi_r() //fibonacci add program that is debugged
{
    int xxx = rnd(n),yyy = rnd(n);
    while(a[xxx][yyy])
    {
        xxx = rnd(n);
        yyy = rnd(n);
    }
    a[xxx][yyy] = 1;
}
bool  LTL_check()
{
    for(int i = 1; i<= n; i ++)
        for(int j = 1; j <= n; j ++)
            if(a[i][j] == 0)    return false;
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
        {
            if((a[j][i] == a[j+1][i] && a[j][i]!=0 && a[j][i] != 1 && a[j][i] != 2) ||(a[j][i] == 1 && a[j + 1][i] == 2) || (a[j][i] == 2 & a[j + 1][i] == 1))  return false;
            if((a[j][i] == a[j][i+1] && a[j][i]!=0 && a[j][i] != 1 && a[j][i] != 2) ||(a[j][i] == 1 && a[j][i + 1] == 2) || (a[j][i] == 2 & a[j][i + 1] == 1))  return false;

        }
        return true;
}
void only_two()
{
    //if (kl==0) cout<<"You out! score:"<<sc,Sleep(2000),exit(0);
    int g=rnd(kl--);
    for (int i=1;i<=n;i++)
        for (int j=1;j<=n;j++)
        {
            if (a[i][j]==16) cout<<"You are win!";//,Sleep(2000),exit(0);
            if (a[i][j]==0){
                g--;
                if (!g) if (rnd(8)==10) a[i][j]=4; else a[i][j]=2;
            }  
        }
}
bool check()
{
    for(int i = 1; i<= n; i ++)
        for(int j = 1; j <= n; j ++)
            if(a[i][j] == 0)    return false;
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
            if(a[i][j] == a[i][j+1] || a[i][j] == a[i+1][j])    return false;
        return true;
}
bool check_fi_out()
{
    for(int i = 1; i<= n; i ++)
        for(int j = 1; j <= n; j ++)
            if(a[i][j] == 0)    return false;
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
            if(check_fi(a[i][j],a[i][j+1]) || check_fi(a[i][j],a[i+1][j]))  return false;
        return true;
}
void d()
{
    kkk= 1;
    char w;
    w=getch();
    if (w=='w'||w =='W'){
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
        {
            int tmp = 0;
            while(a[j][i] == 0 && tmp <=n)
            {   
                for(int k = j;k < n; k++)
                a[k][i] = a[k+1][i];
                a[n][i]= 0;
                tmp++;
            }
            if(tmp < (n-j+1) && tmp > 0)    kkk = 0;    
        }
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
        {
            if(a[j][i] == a[j+1][i] && a[j][i]!=0)
            {
                kl++;
                a[j][i] *=2;
                sc+=a[j][i];
                for(int k = j + 1; k < n; k ++)
                a[k][i] = a[k+1][i];
                a[n][i] = 0;
                kkk = 0;
            }
        }
    }
    else if (w=='a'|| w == 'A'){
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
        {
            int tmp = 0;
            while(a[i][j] == 0 && tmp <=n)
            {   
                for(int k = j;k < n; k++)
                a[i][k] = a[i][k + 1];
                a[i][n]= 0;
                tmp++;
            }
            if(tmp < (n-j+1) && tmp > 0)    kkk = 0;    
        }
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
        {
            if(a[i][j] == a[i][j+1] && a[i][j]!=0)
            {
                kl++;
                a[i][j] *=2;
                sc+=a[i][j];
                for(int k = j + 1; k < n; k ++)
                a[i][k] = a[i][k + 1];
                a[i][n] = 0;
                kkk = 0;
            }
        }
    }
    else if (w=='s' || w == 'S'){
    for(int i = n; i >=1; i --)
        for(int k = 1,j = n; j >= 1; j --,k ++)
        {
            int tmp = 0;
            while(a[j][i] == 0 && tmp <=n)
            {   
                for(int k = j;k >1; k--)
                a[k][i] = a[k-1][i];
                a[1][i]= 0;
                tmp++;
            }
            if(tmp < (n-k+1) && tmp > 0)    kkk = 0;    
        }
    for(int i = n; i >=1; i --)
        for(int j = n; j >=1; j --)
        {
            if(a[j][i] == a[j-1][i] && a[j][i]!=0)
            {
                kl++;
                a[j][i] *=2;
                sc+=a[j][i];
                for(int k = j - 1; k >1; k --)
                a[k][i] = a[k-1][i];
                a[1][i] = 0;
                kkk = 0;
            }
        }
    }
    else if (w=='d'|| w == 'D'){
    for(int i = n;i >= 1; i --)
        for(int j = n,k = 1; j >=1; j --,k ++)
        {
            int tmp = 0;
            while(a[i][j] == 0 && tmp <=n)
            {   
                for(int k = j;k > 1; k--)
                a[i][k] = a[i][k - 1];
                a[i][1]= 0;
                tmp++;
            }
            if(tmp < (n-k+1) && tmp > 0)    kkk = 0;    
        }
    for(int i = n; i >=1; i--)
        for(int j = n; j >=1; j --)
        {
            if(a[i][j] == a[i][j-1] && a[i][j]!=0)
            {
                kl++;
                a[i][j] *=2;
                sc+=a[i][j];
                for(int k = j - 1; k > 1; k --)
                a[i][k] = a[i][k - 1];
                a[i][1] = 0;
                kkk = 0;
            }
        }
    }
    if(check()) cout<<"You out! score:"<<sc,Sleep(2000),exit(0);
    if(kkk) 
    {
        //cout<<"No";
        d();
    }
}
void fi_d()
{
    kkk= 1;
    char w;
    w=getch();
    if (w=='w'||w =='W'){
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
        {
            int tmp = 0;
            while(a[j][i] == 0 && tmp <=n)
            {   
                for(int k = j;k < n; k++)
                a[k][i] = a[k+1][i];
                a[n][i]= 0;
                tmp++;
            }
            if(tmp < (n-j+1) && tmp > 0)    kkk = 0;    
        }
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
        {
            if(check_fi(a[j][i],a[j+1][i]))
            {
                kl++;
                a[j][i] +=a[j+1][i];
                sc+=a[j][i];
                for(int k = j + 1; k < n; k ++)
                a[k][i] = a[k+1][i];
                a[n][i] = 0;
                kkk = 0;
            }
        }
    }
    else if (w=='a'|| w == 'A'){
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
        {
            int tmp = 0;
            while(a[i][j] == 0 && tmp <=n)
            {   
                for(int k = j;k < n; k++)
                a[i][k] = a[i][k + 1];
                a[i][n]= 0;
                tmp++;
            }
            if(tmp < (n-j+1) && tmp > 0)    kkk = 0;    
        }
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
        {
            if(check_fi(a[i][j],a[i][j+1]))
            {
                kl++;
                a[i][j] += a[i][j+1];
                sc+=a[i][j];
                for(int k = j + 1; k < n; k ++)
                a[i][k] = a[i][k + 1];
                a[i][n] = 0;
                kkk = 0;
            }
        }
    }
    else if (w=='s' || w == 'S'){
    for(int i = n; i >=1; i --)
        for(int k = 1,j = n; j >= 1; j --,k ++)
        {
            int tmp = 0;
            while(a[j][i] == 0 && tmp <=n)
            {   
                for(int k = j;k >1; k--)
                a[k][i] = a[k-1][i];
                a[1][i]= 0;
                tmp++;
            }
            if(tmp < (n-k+1) && tmp > 0)    kkk = 0;    
        }
    for(int i = n; i >=1; i --)
        for(int j = n; j >=1; j --)
        {
            if(check_fi(a[j][i],a[j-1][i]))
            {
                kl++;
                a[j][i] +=a[j-1][i];
                sc+=a[j][i];
                for(int k = j - 1; k >1; k --)
                a[k][i] = a[k-1][i];
                a[1][i] = 0;
                kkk = 0;
            }
        }
    }
    else if (w=='d'|| w == 'D'){
    for(int i = n;i >= 1; i --)
        for(int j = n,k = 1; j >=1; j --,k ++)
        {
            int tmp = 0;
            while(a[i][j] == 0 && tmp <=n)
            {   
                for(int k = j;k > 1; k--)
                a[i][k] = a[i][k - 1];
                a[i][1]= 0;
                tmp++;
            }
            if(tmp < (n-k+1) && tmp > 0)    kkk = 0;    
        }
    for(int i = n; i >=1; i--)
        for(int j = n; j >=1; j --)
        {
            if(check_fi(a[i][j] ,a[i][j-1]))
            {
                kl++;
                a[i][j] += a[i][j-1];
                sc+=a[i][j];
                for(int k = j - 1; k > 1; k --)
                a[i][k] = a[i][k - 1];
                a[i][1] = 0;
                kkk = 0;
            }
        }
    }
    if(check_fi_out())  cout<<"You out! score:"<<sc,Sleep(2000),exit(0);
    if(kkk) 
    {
        //cout<<"No";
        fi_d();
    }
}
void LTL()      //LITTLE THREE LEGEND
{
    kkk= 1;
    char w;
    w=getch();
    if (w=='w'||w =='W'){
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
        {
            int tmp = 0;
            while(a[j][i] == 0 && tmp <=n)
            {   
                for(int k = j;k < n; k++)
                a[k][i] = a[k+1][i];
                a[n][i]= 0;
                tmp++;
            }
            if(tmp < (n-j+1) && tmp > 0)    kkk = 0;    
        }
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
        {
            if((a[j][i] == a[j+1][i] && a[j][i]!=0 && a[j][i] != 1 && a[j][i] != 2) ||(a[j][i] == 1 && a[j + 1][i] == 2) || (a[j][i] == 2 & a[j + 1][i] == 1))
            {
                kl++;
                a[j][i] +=a[j+1][i];
                sc+=a[j][i];
                for(int k = j + 1; k < n; k ++)
                a[k][i] = a[k+1][i];
                a[n][i] = 0;
                kkk = 0;
            }
        }
    }
    else if (w=='a'|| w == 'A'){
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
        {
            int tmp = 0;
            while(a[i][j] == 0 && tmp <=n)
            {   
                for(int k = j;k < n; k++)
                a[i][k] = a[i][k + 1];
                a[i][n]= 0;
                tmp++;
            }
            if(tmp < (n-j+1) && tmp > 0)    kkk = 0;    
        }
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
        {
            if((a[i][j] == a[i][j+1] && a[i][j]!=0 && a[i][j+1] != 1 && a[i][j+1] != 2) ||(a[i][j] == 1 && a[i][j+1] == 2) || (a[i][j] == 2 & a[i][j+1] == 1))
            {
                kl++;
                a[i][j] +=a[i][j+1];
                sc+=a[i][j];
                for(int k = j + 1; k < n; k ++)
                a[i][k] = a[i][k + 1];
                a[i][n] = 0;
                kkk = 0;
            }
        }
    }
    else if (w=='s' || w == 'S'){
    for(int i = n; i >=1; i --)
        for(int k = 1,j = n; j >= 1; j --,k ++)
        {
            int tmp = 0;
            while(a[j][i] == 0 && tmp <=n)
            {   
                for(int k = j;k >1; k--)
                a[k][i] = a[k-1][i];
                a[1][i]= 0;
                tmp++;
            }
            if(tmp < (n-k+1) && tmp > 0)    kkk = 0;    
        }
    for(int i = n; i >=1; i --)
        for(int j = n; j >=1; j --)
        {
            if(((a[j][i] == a[j-1][i] && a[j][i]!=0 && a[j][i] != 1 && a[j][i] != 2) ||(a[j][i] == 1 && a[j - 1][i] == 2) || (a[j][i] == 2 & a[j-1][i] == 1)))
            {
                kl++;
                a[j][i] +=a[j-1][i];
                sc+=a[j][i];
                for(int k = j - 1; k >1; k --)
                a[k][i] = a[k-1][i];
                a[1][i] = 0;
                kkk = 0;
            }
        }
    }
    else if (w=='d'|| w == 'D'){
    for(int i = n;i >= 1; i --)
        for(int j = n,k = 1; j >=1; j --,k ++)
        {
            int tmp = 0;
            while(a[i][j] == 0 && tmp <=n)
            {   
                for(int k = j;k > 1; k--)
                a[i][k] = a[i][k - 1];
                a[i][1]= 0;
                tmp++;
            }
            if(tmp < (n-k+1) && tmp > 0)    kkk = 0;    
        }
    for(int i = n; i >=1; i--)
        for(int j = n; j >=1; j --)
        {
            if((a[i][j] == a[i][j-1] && a[i][j]!=0 && a[i][j-1] != 1 && a[i][j-1] != 2) ||(a[i][j] == 1 && a[i][j-1] == 2) || (a[i][j] == 2 & a[i][j-1] == 1))
            {
                kl++;
                a[i][j] +=a[i][j-1];
                sc+=a[i][j];
                for(int k = j - 1; k > 1; k --)
                a[i][k] = a[i][k - 1];
                a[i][1] = 0;
                kkk = 0;
            }
        }
    }
    if(LTL_check()) cout<<"You out! score:"<<sc,Sleep(2000),exit(0);
    if(kkk) 
    {
        //cout<<"No";
        LTL();
    }
}

void merg()
{
    kkk= 1;
    char w;
    w=getch();
    if (w=='w'||w =='W'){
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
        {
            int tmp = 0;
            while(a[j][i] == 0 && tmp <=n)
            {   
                for(int k = j;k < n; k++)
                a[k][i] = a[k+1][i];
                a[n][i]= 0;
                tmp++;
            }
            if(tmp < (n-j+1) && tmp > 0)    kkk = 0;    
        }
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
        {
                kl++;
                a[j][i] +=a[j+1][i];
                sc+=a[j][i];
                for(int k = j + 1; k < n; k ++)
                a[k][i] = a[k+1][i];
                a[n][i] = 0;
                kkk = 0;
        }
    }
    else if (w=='a'|| w == 'A'){
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
        {
            int tmp = 0;
            while(a[i][j] == 0 && tmp <=n)
            {   
                for(int k = j;k < n; k++)
                a[i][k] = a[i][k + 1];
                a[i][n]= 0;
                tmp++;
            }
            if(tmp < (n-j+1) && tmp > 0)    kkk = 0;    
        }
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
        {
                kl++;
                a[i][j] +=a[i][j+1];
                sc+=a[i][j];
                for(int k = j + 1; k < n; k ++)
                a[i][k] = a[i][k + 1];
                a[i][n] = 0;
                kkk = 0;
        }
    }
    else if (w=='s' || w == 'S'){
    for(int i = n; i >=1; i --)
        for(int k = 1,j = n; j >= 1; j --,k ++)
        {
            int tmp = 0;
            while(a[j][i] == 0 && tmp <=n)
            {   
                for(int k = j;k >1; k--)
                a[k][i] = a[k-1][i];
                a[1][i]= 0;
                tmp++;
            }
            if(tmp < (n-k+1) && tmp > 0)    kkk = 0;    
        }
    for(int i = n; i >=1; i --)
        for(int j = n; j >=1; j --)
        {
                kl++;
                a[j][i] +=a[j-1][i];
                sc+=a[j][i];
                for(int k = j - 1; k >1; k --)
                a[k][i] = a[k-1][i];
                a[1][i] = 0;
                kkk = 0;
        }
    }
    else if (w=='d'|| w == 'D'){
    for(int i = n;i >= 1; i --)
        for(int j = n,k = 1; j >=1; j --,k ++)
        {
            int tmp = 0;
            while(a[i][j] == 0 && tmp <=n)
            {   
                for(int k = j;k > 1; k--)
                a[i][k] = a[i][k - 1];
                a[i][1]= 0;
                tmp++;
            }
            if(tmp < (n-k+1) && tmp > 0)    kkk = 0;    
        }
    for(int i = n; i >=1; i--)
        for(int j = n; j >=1; j --)
        {
                kl++;
                a[i][j] +=a[i][j-1];
                sc+=a[i][j];
                for(int k = j - 1; k > 1; k --)
                a[i][k] = a[i][k - 1];
                a[i][1] = 0;
                kkk = 0;
        }
    }
    //if(check())   cout<<"You out! score:"<<sc,Sleep(2000),exit(0);
    if(kkk) 
    {
        //cout<<"No";
        d();
    }
}
void stnd()     //std
{
    r();
    while(1)
    {
        r();
        outp();
        d();
    }   
}
void ot()       //only_two
{
    only_two();
    while(1)
    {
        only_two();
        outp();
        d();
    }   
}
void ltl()          //LITTLE THREE LEGEND
{
    ltl_output();
    while(1)
    {
        ltl_output();
        outp();
        LTL();
    }
}
void first()
{
    int ty;
    scanf("%d",&ty);
    switch(ty)
    {
        case 0:{    
#if __STD
            SMALL_RECT winPon={0,0,n*7+1,3*n+2};
            HANDLE con=GetStdHandle(STD_OUTPUT_HANDLE);
            SetConsoleWindowInfo(con,true,&winPon);
            stnd();
#else 
            cout<<__ERROR_0;
            Sleep(2000);
#endif
        }
            break;
        case 2:{
#if __ONLY2
            SMALL_RECT winPon={0,0,n*7+1,3*n+2};
            HANDLE con=GetStdHandle(STD_OUTPUT_HANDLE);
            SetConsoleWindowInfo(con,true,&winPon);
            ot();
#else 
            cout<<__ERROR_0;
            Sleep(2000);
#endif
            break;
        }
        case 4:{
#if __MS 
            SMALL_RECT winPon={0,0,n*7+1,3*n+2};
            HANDLE con=GetStdHandle(STD_OUTPUT_HANDLE);
            SetConsoleWindowInfo(con,true,&winPon);
            addd();
            while(1)
            {
                addd();
                outp();
                merg();
            }   
#else
            cout<<__ERROR_0;
            Sleep(2000);
#endif
            break;
        }
        case 1:{
#if __LITTLE3 
            SMALL_RECT winPon={0,0,n*7+1,3*n+2};
            HANDLE con=GetStdHandle(STD_OUTPUT_HANDLE);
            SetConsoleWindowInfo(con,true,&winPon);
            ltl();
#else
            cout<<__ERROR_0;
            Sleep(2000);
#endif
            break;

        }
        case 3:{    
#if __FEB
            SMALL_RECT winPon={0,0,n*7+1,3*n+2};
            HANDLE con=GetStdHandle(STD_OUTPUT_HANDLE);
            SetConsoleWindowInfo(con,true,&winPon);
            while(1)
            {
                fi_r();
                outp();
                fi_d();
            }
#else
            cout<<__ERROR_0;
            Sleep(2000);
#endif
            break;

        }
        case 5:{
#if __LIMIT 
            SMALL_RECT winPon={0,0,n*7+1,3*n+2};
            HANDLE con=GetStdHandle(STD_OUTPUT_HANDLE);
            SetConsoleWindowInfo(con,true,&winPon);
            lim();
#else
            cout<<__ERROR_0;
            Sleep(2000);
#endif
            break;
        }
    }
    
}
int main() {
    srand((unsigned)time(NULL)); 
    cout<<" 2048 2.0\n  Name: 2048 Game\n   Copyright: W.Guo & X.Y.Zhang All Rights Reserved.\n Author: 4096 Team from 192.168.45.99 LJOJ\n Date: 14/07/17 14:29\n  Description: Join the numbers and get to the 2048 tile! \n  The Specialty of the Refreshment 2.0: added more types of the games."<<endl;
    cout<<" Now,please input the number of the size of the game(<=10)"<<endl;
    cin>>n;
    kl=n*n;
    cout<<" Now,please give a number of your game type"<<endl;
    cout<<" 0: standard\n 1: Little Three Legend\n 2: Only two\n 3: Fibonacci\n 4: Merge Any(entertainment)\n 5: Time Limitation Mode(debugging)\n";
    first();
}

4 条评论

  • 1