List all the position that two kings not encounter in Chinese chess
来源:互联网 发布:计算机编程原理书籍 编辑:程序博客网 时间:2024/06/06 03:56
Title like , there are many ways to resolve this question , but if request you can only use one variable , how to do it .
For use one variable to resolve this question , we can set a eight bit binary variable , every four bit express one kings position . the can solve it . the code not list below .
There are some more convenient solution . just like this
$i = 81;while ($i--) {if ($i / 9 % 3 == $i % 9 % 3) {continue;}printf("A=%d,B=%d\n",$i / 9 + 1,$i % 9 + 1);}
And we can use php array also:
$array = array(0,0);for ($array[0] = 1;$array[0] <= 9 ; $array[0]++){for ($array[1] = 1;$array[1] <= 9;$array[1]++){if ($array[0] % 3 != $array[1] % 3) {printf("a=%d,b=%d\n",$array[0],$array[1]);}}}
- List all the position that two kings not encounter in Chinese chess
- An issue that you may encounter in the future
- CareerCup Find the biggest interval that has all its members in list in O(n)
- CareerCup Finds all the elements that appear more than n/3 times in the list
- List all in the Directory
- The proof is in the code. That is all.
- What is that Scope all about (Chinese)
- Found 2 versions of android-support-v4.jar in the dependency list,but not all the versions are ident
- CareerCup Write a function that given a position returns the digit in that 0123456789101112131415..
- translation:Achieving of Chinese Display in the embedded graphical user interface of uC/GUI in Two
- Tutorial:What is that Scope all about (Chinese) 学习
- 证据就在代码里(The proof is in the code. That is all.)
- The website that specifed all of the differences in internation-normalized Character-set
- CareerCup Fill the array with product of all numbers except the number in that cell
- 60.In which of the scenarios will the DBA perform recovery? (Choose all that apply.)
- calculate all controls size and position in the form when the form resize
- List All Of The Subset In Another Method
- List the maximum or minimum of the elements at each position of two arrays
- Spring Security3十五日研究
- ASPX 1句话SHELL
- 二十二年来的总结回首
- 清理一下,总结一番
- J2ME 打混淆包
- List all the position that two kings not encounter in Chinese chess
- Dalvik和JVM的几点区别
- JSF的rich:editor的相关参数
- sql round()函数的用法
- C++沉思录读书笔记(21,22章)- 函数对象存在的意义以及自定义能应用bind1st(bind2nd)的函数对象模板
- 关闭SELinux的方法
- C 位运算 2
- 用ibatis selectKey 返回自动生成的主键值
- 简单标签