c#象棋程序

A chess board is equally divided into 64 identical squares that are black and white alternately. Each square on the chessboard can be identified by the coordinates as 'A' to 'H' on the horizontal axis and '1' to '8' on the vertical axis as shown in the figure.

一块国际象棋棋盘平均分为64个相同的正方形,它们是黑白交替的 。 如图所示,可以通过在水平轴上的坐标从“ A”到“ H”以及在垂直轴上的“ 1”到“ 8”来标识棋盘上的每个正方形。

Each square can be identified using the coordinate system specified above. For example, the square with coordinates G5 is colored Black, A6 is colored White and so on...

可以使用上面指定的坐标系来标识每个正方形。 例如, 坐标为G5的正方形为黑色A6为白色 ,依此类推...

A program to identify the color of a specified square is given below.

下面给出识别指定正方形颜色的程序。

在C ++中确定国际象棋方板的颜色 (Determine the color of a chess square board in C++)

#include<iostream>
#include<cctype>
using namespace std;
int main()
{char string[10], x;
cout << "Enter the coordinates of the square, \
\nthe first coordinate A to H and second coordinate 1 to 8: ";
cin.getline(string, 10);
x = string[0];
x = tolower(x);
string[0] = x;
if (string[0] == 'a' || string[0] == 'c' || string[0] == 'e' || string[0] == 'g')
{if (string[1] == '1' || string[1] == '3' || string[1] == '5' || string[1] == '7')
cout << "Black square";
else
cout << "White square";
}
else
{if (string[1] == '1' || string[1] == '3' || string[1] == '5' || string[1] == '7')
cout << "white square";
else
cout << "Black square";
}
return 0;
}

Output

输出量

First run:
Enter the coordinates of the square,
the first coordinate A to H and second coordinate 1 to 8: C5
Black square
Seccond run:
Enter the coordinates of the square,
the first coordinate A to H and second coordinate 1 to 8: F3
white square

翻译自: https://www.includehelp.com/cpp-programs/determine-the-color-of-chess-square.aspx

c#象棋程序

c#象棋程序_C ++程序确定象棋方块的颜色相关推荐

  1. ad转换汇编语言程序_C程序如何转换成汇编

    ad转换汇编语言程序 在较早的文章中,我们已经了解了C运行时:启动main和如何将C程序存储在RAM存储器中之前 . 在这里,我们将看到" C程序如何转换为程序集?" 以及它在机器 ...

  2. mysql数据库访问程序_c++程序访问MySQL数据库操作示例

    1.安装mysql sudo apt-get install mysql-server mysql-client 安装过程中会提示设置用户名和密码 2.启动mysql sudo /etc/init.d ...

  3. 红外接收器c语言软件,红外线遥控解码接收程序_C语言.doc

    红外线遥控解码接收程序_C语言.doc (9页) 本资源提供全文预览,点击全文预览即可全文预览,如果喜欢文档就下载吧,查找使用更方便哦! 14.9 积分 红外线遥控解码接收程序-C语言.txt铁饭碗 ...

  4. nec c语言笔试题,红外NEC编码发射程序_C语言(国外英文资料).doc

    红外NEC编码发射程序_C语言(国外英文资料) 红外NEC编码发射程序_C语言(国外英文资料) * * * * * * * Hardware platform: homemade infrared d ...

  5. 计算机中国象棋书籍,[建议]中国的象棋永远不能被没有“思维”的电脑所代替(就目前的电脑象棋软件...

    [建议]中国的象棋永远不能被没有"思维"的电脑所代替(就目前的电脑象棋软件有感而发) 先自我介绍一下,本人来自上海,师从原江苏省棋队教练言穆江大师,现年28岁,无任何值得自傲的成绩 ...

  6. 计算机 程序 原理,计算机储存程序和程序原理是谁提出来的

    大家好,我是时间财富网智能客服时间君,上述问题将由我为大家进行解答. 计算机储存程序和程序原理是由美籍匈牙利数学家冯・诺依曼于1946年提出的,意思是把程序本身当作数据来对待,程序和该程序处理的数据用 ...

  7. IOS 后台挂起程序 当程序到后台后,继续完成Long Running Task 任务

    IOS 后台挂起程序 当程序到后台后,继续完成Long-Running Task 任务 www.douban.com/note/375127- http://lqzit.iteye.com/blog/ ...

  8. matlab多元回归程序,多元回归程序MATLAB程序

    <多元回归程序MATLAB程序>由会员分享,可在线阅读,更多相关<多元回归程序MATLAB程序(45页珍藏版)>请在人人文库网上搜索. 1.程序MATLAB多元回归程序matl ...

  9. c语言做小学生测验程序,[转载]程序设计方法学课程设计--小学生算术四则运算测试程序(C)...

    背景 伴随着人类社会的进步,人们的计算工具也在不断的变化,从远古时期的结绳计数,到算筹,算盘,以及近代的机械计算机.计算尺,直至今天我们广泛运用的电子计算机.计算工具的每一次进步,都导致科学技术发生深 ...

最新文章

  1. linux延时与定时计算
  2. DSDT亮度修复失败
  3. WF(工作流)模块介绍
  4. 今晚直播 | NeurIPS 2021论文解读:基于置信度校正的可信图神经网络
  5. Android UI开发第二篇——多级列表(ExpandableListView)
  6. MyEclipse+JavaEE+jsp+sqlsever实现产品售后服务系统
  7. Java LinkedList对象的get(int index)方法与示例
  8. Linux Wireless架构总结
  9. c语言如何关闭线程,如何用C语言实现多线程
  10. 44. 扑克牌的顺子(C++版本)
  11. ArcGIS相关学习视频链接
  12. 【知识碎片】JavaScript篇
  13. win8计算机无法安装打印机驱动程序,win8系统安装打印机驱动失败怎么办|win8系统安装打印机驱动失败的解决方法...
  14. CTR预估 论文精读(十七)--ESMM: Entire Space Multi-Task Model
  15. 2020.07-Study_update.5
  16. 【工艺】 CNC(数控机床)加工工艺
  17. npm/package.json/package-lock.json文件
  18. win7 mysql 管理员权限_win7 管理员权限
  19. vue form表单验证清除
  20. Generator cannot target libraries that have not been migrated to null-safety.

热门文章

  1. 计算机护理职称考试报名时间2015,护理职称考试怎么报名?
  2. Qt图形界面编程入门(5)
  3. php js记住密码功能,jquery.cookie.js实现用户登录保存密码功能的方法_jquery
  4. java求二维数组每行的最大值_用JAVA输入一个二维数组a[3][4]的元素值,求输出其元素最大值...
  5. 等待的操作过时_不会过时的6种网站seo优化操作
  6. 刷网络课_网络营销实践心得—刘荟萌
  7. DataParallel 和 DistributedDataParallel 的区别和使用方法
  8. Linux namespace之:uts namespace
  9. 添加自定义监控项目,配置邮件告警,测试告警,不发邮件的问题处理
  10. 为什么公司要努力发展数字化战略