poj1552

简单题

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

#define maxn 20

int n;
int f[maxn];

void input()
{
    n = 0;
    while (scanf("%d", &f[n]), f[n])
    {
        if (f[n] == -1)
            exit(0);
        n++;
    }
}

void work()
{
    int ans = 0;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            if (f[i] == f[j] * 2)
                ans++;
    printf("%d\n", ans);
}

int main()
{
    while (1)
    {
        input();
        work();
    }
}

 

posted @ 2013-04-03 17:02  金海峰  阅读(429)  评论(0编辑  收藏  举报