UVALive 4853 Emoogle Balance

题意:题目很长,其实主要就是题中加粗的那个公式和输入输出。给n个数,用非零数的个数减去零的个数。

水题啦~

#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int a[1005];

int main()
{
    int ans, cnt = 1, n;
    while(~scanf("%d", &n))
    {
        ans = 0;
        if(n == 0)
            break;
        int b;
        for(int i = 0; i < n; i++)
        {
            scanf("%d", &b);
            if(b == 0)
                ans--;
            else
                ans++;
        }
        printf("Case %d: %d\n", cnt++, ans);
    }
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章