poj3917

简单题

View Code
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
using namespace std;

#define maxn 105

char st1[maxn], st2[maxn];

int main()
{
    while (true)
    {
        scanf("%s", st1);
        scanf("%s", st2);
        if (st1[0] == 'E')
            break;
        int p1, p2;
        p1 = p2 = 0;
        int n = strlen(st1);
        for (int i = 0; i < n; i++)
        {
            if (st1[i] == st2[i])
                continue;
            if ((st1[i] == 'R' && st2[i] == 'S') || (st1[i] == 'S' && st2[i] == 'P') || (st1[i] == 'P' && st2[i] == 'R'))
                p1++;
            else
                p2++;
        }
        printf("P1: %d\nP2: %d\n", p1, p2);
    }
    return 0;
}
posted @ 2012-10-23 17:02  金海峰  阅读(135)  评论(0编辑  收藏  举报