problemscpp
A collection of my answers to algorithm problems in c++.
| 枚举 | 函数
acwing::acwing1929 命名空间参考

AcWing 1929. 镜子田地 更多...

class  Solution
 
struct  step
 行动 更多...
 
struct  step_equal
 
struct  step_hash
 

枚举

enum  direction { left , right , up , down }
 方向 更多...
 

函数

direction operator! (const direction &d)
 取反方向 更多...
 
direction reflect (direction d, char mirror)
 方向经过镜子反射后的变化 更多...
 
 TEST (acwing1929, case1)
 

详细描述

AcWing 1929. 镜子田地

日期
2022-01-18

枚举类型说明

◆ direction

方向

枚举值
left 

right 

up 

down 

在文件 acwing.h548 行定义.

548 {
550 left,
552 right,
554 up,
556 down
557 };

函数说明

◆ operator!()

direction acwing::acwing1929::operator! ( const direction d)

取反方向

参数
d方向
返回
d的反方向

在文件 acwing.cpp1711 行定义.

1711 {
1712 switch(d) {
1713 case left: {
1714 return right;
1715 }
1716 case right: {
1717 return left;
1718 }
1719 case up: {
1720 return down;
1721 }
1722 case down: {
1723 return up;
1724 }
1725 }
1726 return {};
1727 }

引用了 down, left, right , 以及 up.

◆ reflect()

direction acwing::acwing1929::reflect ( direction  d,
char  mirror 
)

方向经过镜子反射后的变化

参数
d方向
mirror镜子
返回
方向经过镜子反射后的变化

在文件 acwing.cpp1669 行定义.

1669 {
1670 switch(d) {
1671 case left: {
1672 if(mirror == '/') {
1673 return down;
1674 }
1675 if(mirror == '\\') {
1676 return up;
1677 }
1678 break;
1679 }
1680 case right: {
1681 if(mirror == '/') {
1682 return up;
1683 }
1684 if(mirror == '\\') {
1685 return down;
1686 }
1687 break;
1688 }
1689 case up: {
1690 if(mirror == '/') {
1691 return right;
1692 }
1693 if(mirror == '\\') {
1694 return left;
1695 }
1696 break;
1697 }
1698 case down: {
1699 if(mirror == '/') {
1700 return left;
1701 }
1702 if(mirror == '\\') {
1703 return right;
1704 }
1705 break;
1706 }
1707 }
1708 return {};
1709 }

引用了 down, left, right , 以及 up.

被这些函数引用 acwing::acwing1929::Solution::count_reflect().

◆ TEST()

acwing::acwing1929::TEST ( acwing1929  ,
case1   
)

在文件 acwing_test.cpp948 行定义.

948 {
949 istringstream in("3 3\n"
950 "/ \\ \\ \n"
951 "\\ \\ \\ \n"
952 "/ \\ / \n");
953 auto out = ostringstream();
954 auto sol = Solution();
955 sol.main(in, out);
956 const auto ans = out.str();
957 ASSERT_EQ("3", ans);
958 }