codeforces水题100道 第十六题 Codeforces Round #164 (Div. 2) A. Games (brute force)

题目链接:http://www.codeforces.com/problemset/problem/268/A
题意:足球比赛中如果主场球队的主场球衣和客队的客队球衣颜色一样,那么要求主队穿上他们的可对球衣,现在有n个球队,每一球队的主场球衣和客场球衣的颜色都告诉你了,它们两两之间要比一场赛。求其中主队穿客场球衣的比赛场数。
C++代码:

#include <iostream>
using namespace std;
const int maxn = 33;
int x[maxn], y[maxn], n, ans;
int main()
{
    cin >> n;
    for (int i =0 ; i< n; i++)
        cin >> x[i] >> y[i];
    for (int i = 0; i< n;i ++)
        for (int j = 0; j<n; j ++)
        {
            if (i == j) continue;
            if (x[i] == y[j])
                ans ++;
        }
    cout << ans;
    return 0;
}
C++

 

posted @ 2016-07-20 17:58  月光诗人  阅读(267)  评论(0编辑  收藏  举报