| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
水题,贴一下#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator