You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <stdio.h>
#include<windows.h>
#include<iostream>
/*定义三个函数*/
void White(){
{ 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 Yellow()
{/*打印国际象棋棋盘*/
/*用不了图库用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 Goodbye(){printf("Goodbye!\n");}
/*驱动实现*/
int main()
{
/*设置退出开关的状态*/
bool quit=false;
int input;
/*循环*/
while(!quit)
{
/*打印菜单*/
printf("欢迎绘制国家象棋棋盘\n");
printf("请输入数字代表你想要的颜色\n") ;
printf("1.Yellow 2.White 3.Goodbye! Input 1-3:");
/*接收输入*/
input=getchar()-0x30,getchar();
/*选择分支*/
switch(input)
{
case 1:White();quit=true;break;
case 2:Yellow();quit=true;break;
case 3:Goodbye();quit=true;break;
default:break;
}
}
}