# OJ question-Scissors, stones and cloth, oj question Scissors Stone

Source: Internet
Author: User

OJ question-Scissors, stones and cloth, oj question Scissors Stone

/*
* Copyright (c) 2014, computer College, Yantai University
* 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 ;}

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.