LightOJ-1015-Brush (I)


題目傳送門


題意:求輸入的灰塵的總體積,負數不考慮。

思路:求和。

#include <bits/stdc++.h>

using namespace std;

int main(void)
{
    int T, cas = 1;
    scanf("%d", &T);
    while (T--)
    {
        int sum=0, n,x;
        scanf("%d", &n);
        while (n--)
        {
            scanf("%d", &x);
            if (x>0)
                sum+=x;
        }
        printf("Case %d: %d\n", cas++, sum);
    }
    return 0;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章