commit 3ea00b5d14d6ba75d3a31d43426b3035bd3b528b Author: 760034931@qq.com <760039431@qq.com> Date: Thu Jan 10 14:25:10 2019 +0800 first commit diff --git a/中国象棋棋盘.cpp b/中国象棋棋盘.cpp new file mode 100644 index 0000000..24ae9e6 --- /dev/null +++ b/中国象棋棋盘.cpp @@ -0,0 +1,116 @@ +#include +#include + +void DrawCheckerBoard(); +void DrawStartMenu(); +void ClearPanel(); +void goto_xy(int x,int y); +void Write(int x,int y,const char* str); + +#define WIDTH 100 +#define HEIGHT 60 + +int main() { + +int input=-1; +//char input='9'; +char a; +system("mode con:cols=100 lines=60"); //ÉèÖô°¿ÚΪ100ÁУ¬60ÐдóС +SetConsoleOutputCP(437); + +DrawStartMenu(); + + while(input!=0){ + //cin>>input; //»ñÈ¡ÊäÈë + + scanf("%d",&a); + getchar(); + input=(int)a; + + if(input>2||input<0){ + printf("The input is wrong,please enter again."); + continue; + } + else if(input==1) + DrawCheckerBoard(); + else if(input==2) + DrawStartMenu(); + } + return 0; +} + +//»æÖÆ¿ªÊ¼²Ëµ¥ +void DrawStartMenu(){ + + ClearPanel(); +printf(" ************************\n"); +printf(" chinese chess\n"); +printf(" ************************"); + +Write(40,11,"0-Exit Game"); +Write(40,12,"1-Start Game"); +Write(40,13,"2-StartMenu"); +Write(30,15,"Please press 0 OR 1 to select:"); +} + +//»æÖÆÆåÅÌ +void DrawCheckerBoard(){ + ClearPanel(); + +{int r=0; + int c=0; + int star_one=10; + for(r=0;r<=star_one*9;r+=2) + { for(c=0;c<=star_one*8;c+=2) + {if((r%star_one==0 || c%star_one==0)&&c%2==0 && (r<=star_one*4 || r>=star_one*4+star_one) || (r>=star_one*4 && r<=star_one*4+star_one && (c==0 || c==star_one*8)) + ||((r==2||r==18||r==88||r==72)&&(c==32||c==48)) + ||((r==4||r==16||r==86||r==74)&&(c==34||c==46)) + ||((r==6||r==14||r==84||r==76)&&(c==36||c==44)) + ||((r==8||r==12||r==82||r==78)&&(c==38||c==42))) + {printf("%c",'*');} + else + {printf("%c",' ');} + } + printf("\n"); + } +} +} + +//ÇåÀíÆÁÄ» +void ClearPanel(){ + for(int i=0;i>userName; +// printf("Please press PassWord"); +// cin>>passWord; +// +// str[0]=userName; +// str[1]=passWord; +// return str; +//} + +void goto_xy(int x,int y){ //¶¨Î»¹â±êλÖõ½Ö¸¶¨×ø±ê +HANDLE hOut; +hOut = GetStdHandle(STD_OUTPUT_HANDLE); +COORD pos={x,y}; +SetConsoleCursorPosition(hOut,pos); +} + +//´ÓÖ¸¶¨Î»ÖÿªÊ¼»æÖÆÎÄ×Ö +void Write(int x,int y,const char* str){ + goto_xy(x,y); + printf(str); +} + diff --git a/中国象棋棋盘.exe b/中国象棋棋盘.exe new file mode 100644 index 0000000..241a68c Binary files /dev/null and b/中国象棋棋盘.exe differ