|
|
|
@ -0,0 +1,137 @@
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include<windows.h>
|
|
|
|
|
#include<iostream>
|
|
|
|
|
/*定义6个函数*/
|
|
|
|
|
void Yellow(){
|
|
|
|
|
{ system("color e");
|
|
|
|
|
for(int i=0;i<8;i++)
|
|
|
|
|
{
|
|
|
|
|
for(int j=0;j<8;j++)
|
|
|
|
|
{
|
|
|
|
|
if((i+j)%2==0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("%c%c",168,128);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf(" ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void White()
|
|
|
|
|
{/*打印国际象棋棋盘*/
|
|
|
|
|
/*无法调出图库,用ascall码168和128以及空格代替棋盘格子*/
|
|
|
|
|
for(int i=0;i<8;i++)
|
|
|
|
|
{
|
|
|
|
|
for(int j=0;j<8;j++)
|
|
|
|
|
{
|
|
|
|
|
if((i+j)%2==0)
|
|
|
|
|
{
|
|
|
|
|
printf("%c%c",168,128);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf(" ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void Red(){
|
|
|
|
|
{ system("color c");
|
|
|
|
|
for(int i=0;i<8;i++)
|
|
|
|
|
{
|
|
|
|
|
for(int j=0;j<8;j++)
|
|
|
|
|
{
|
|
|
|
|
if((i+j)%2==0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("%c%c",168,128);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf(" ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void Blue(){
|
|
|
|
|
{ system("color 9");
|
|
|
|
|
for(int i=0;i<8;i++)
|
|
|
|
|
{
|
|
|
|
|
for(int j=0;j<8;j++)
|
|
|
|
|
{
|
|
|
|
|
if((i+j)%2==0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("%c%c",168,128);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf(" ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void Purple(){
|
|
|
|
|
{ system("color d");
|
|
|
|
|
for(int i=0;i<8;i++)
|
|
|
|
|
{
|
|
|
|
|
for(int j=0;j<8;j++)
|
|
|
|
|
{
|
|
|
|
|
if((i+j)%2==0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("%c%c",168,128);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf(" ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void Goodbye(){printf("Goodbye!\n");}
|
|
|
|
|
/*不想绘制就goodbye*/
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
/*设置退出开关的状态*/
|
|
|
|
|
bool quit=false;
|
|
|
|
|
int input;
|
|
|
|
|
/*循环*/
|
|
|
|
|
while(!quit)
|
|
|
|
|
{
|
|
|
|
|
/*打印菜单*/
|
|
|
|
|
printf("欢迎绘制国家象棋棋盘\n");
|
|
|
|
|
printf("请输入数字代表你想要的颜色\n") ;
|
|
|
|
|
printf(" 1.Yellow\n 2.White\n 3.Blue\n 4.Red\n 5.Purple\n 6.Goodbye! Input 1-6:");
|
|
|
|
|
/*接收输入,限定1-6为合法的字符*/
|
|
|
|
|
input=getchar()-0x30,getchar();
|
|
|
|
|
/*选择分支*/
|
|
|
|
|
switch(input)
|
|
|
|
|
{
|
|
|
|
|
case 1:Yellow();quit=true;break;/*绘制完成,退出*/
|
|
|
|
|
case 2:White();quit=true;break;
|
|
|
|
|
case 3:Blue();quit=true;break;
|
|
|
|
|
case 4:Red();quit=true;break;
|
|
|
|
|
case 5:Purple();quit=true;break;
|
|
|
|
|
case 6:Goodbye();quit=true;break;
|
|
|
|
|
default:break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|