Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

水题,贴一下

Posted by KatrineYang at 2017-01-23 05:59:47 on Problem 3917
#include <iostream>
#include <string>
using namespace std;

bool larger(char c1, char c2){
	if(c1=='R' && c2=='S') return true;
	if(c1=='S' && c2=='P') return true;
	if(c1=='P' && c2=='R') return true;
	return false;
}

int main() {
	string s1, s2;
	while(cin >> s1 >> s2){
		if(s1[0] == 'E') break;
		int w1=0, w2=0;
		int sz = s1.length();
		for(int i = 0; i < sz; i++){
			if(larger(s1[i], s2[i])) w1++;
			else if(larger(s2[i], s1[i])) w2++;
		}
		cout << "P1: " << w1 << endl << "P2: " << w2 << endl;
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator