Sunday, September 13, 2015

Lightoj 1015 in C++

Brush(1):

#include<iostream>
#include<cstdio>
using namespace std;

int main()
{
    int test,number,sum,N;
    while(cin>>test)
    {
        getchar();//                  It will take a new line as a character.
        for(int i=1;i<=test;i++)
        {
            sum=0;
            getchar();//               It will take a new line as a character.
            cin>>N;
            for(int j=0;j<N;j++)
            {
                cin>>number;
                if(number>=0)
                    sum = sum + number;
            }
            printf("Case %d: %d\n",i,sum);
        }
    }
    return 0;
}

1 comment: