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

  1. 果壳游戏
更多...

函数

int main (istream &cin, ostream &cout)
 
 TEST (acwing1695, case1)
 

详细描述

  1. 果壳游戏

函数说明

◆ main()

int acwing::acwing1695::main ( istream &  cin,
ostream &  cout 
)

在文件 acwing.cpp5775 行定义.

5775 {
5776 bool nuts[3][3] = {{true, false, false},
5777 {false, true, false},
5778 {false, false, true}};
5779 unsigned short score[3] = {0, 0, 0};
5780 unsigned short ans = 0;
5781 unsigned short n;
5782 cin >> n;
5783 unsigned short a;
5784 unsigned short b;
5785 unsigned short g;
5786 for(unsigned short i = 0; i < n; i++) {
5787 cin >> a >> b >> g;
5788 a--;
5789 b--;
5790 g--;
5791 for(unsigned short j = 0; j < 3; j++) {
5792 swap(nuts[j][a], nuts[j][b]);
5793 if(nuts[j][g]) {
5794 score[j]++;
5795 }
5796 }
5797 }
5798 for(unsigned short i = 0; i < 3; i++) {
5799 ans = max(ans, score[i]);
5800 }
5801 cout << ans;
5802 return 0;
5803 }

被这些函数引用 TEST().

◆ TEST()

acwing::acwing1695::TEST ( acwing1695  ,
case1   
)

在文件 acwing_test.cpp2747 行定义.

2747 {
2748 istringstream in("3\n"
2749 "1 2 1\n"
2750 "3 2 1\n"
2751 "1 3 1");
2752 auto out = ostringstream();
2753 main(in, out);
2754 const auto ans = out.str();
2755 ASSERT_EQ("2", ans);
2756 }
int main(int argc, char **argv)
Definition: main.cpp:5

引用了 main().