OJ question-Scissors, stones and cloth, oj question Scissors Stone
/*
* Copyright (c) 2014, computer College, Yantai University
* All rights reserved.
* File name: test. cpp
* Author: Li xiaokai
* Completion date: January 1, May 5, 2015
* Version No.: v1.0
*
* Problem description:
* Input description:
* Program output:
*/
Note: you only need to submit part of the code for this question. Please submit it in C ++ mode.
Zhang Sanhe and Li Si used the five-game and three-win system to determine the victory and defeat through the game of scissors, stone and cloth.
# Include <iostream>
Using namespace std;
Int win (int x, int y)
{
/*
Enter this part of code
*/
}
Int main ()
{
Int I, x, y, sum = 0;
Const int N = 5;
For (I = 0; I <N; I ++ ){
Cin> x> y;
Sum + = win (x, y );
}
If (sum <0)
Cout <"three wins" <endl;
Else
Cout <"Li sisheng" <endl;
Return 0;
}
Input
Enter 5 game battles (no draw), 1 stands for scissors, 2 stands for stones, and 3 stands for cloth.
Output
Who wins
Sample Input
1 22 31 32 33 1
Sample output
Zhang Sansheng
Code:
# Include <iostream> using namespace std; int win (int x, int y) {int a = 1, B =-1; if (y-x = 1 | y-x = 2) return B; else return a;} int main () {int I, x, y, sum = 0; const int N = 5; for (I = 0; I <N; I ++) {cin> x> y; sum + = win (x, y);} if (sum <0) cout <"Zhang Sansheng" <endl; else cout <"Li sisheng" <endl; return 0 ;}