Why WA, where am I wrong?
#include <stdio.h>
#include <iostream>
#include <iterator>
using namespace std;
int main()
{
int n;
while(scanf("%d",&n)&&n!=0){
std::istream_iterator<int> int_it(cin),end;
int sum=*int_it++;
for(int i=2;i<n;++i)
{
sum+=*int_it++;
if(sum<0)
sum=0;
}
sum+=*int ...
Search found 3 matches
- Sat Apr 20, 2013 7:21 pm
- Forum: Volume 106 (10600-10699)
- Topic: 10684 - The jackpot
- Replies: 34
- Views: 25253
- Thu Mar 21, 2013 6:48 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10018 - Reverse and Add
- Replies: 169
- Views: 43952
Re: 10018 - Reverse and Add
My code generates all the correct outputs,.. still getting WA. Can anyone figure out where am I wrong....
Got that.. thanks brian fry. I didnt notice my first char is a null. cmd in windows showed that as space :/
Code: Select all
Accepted
- Fri Mar 01, 2013 6:20 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10070 - Leap Year or Not Leap Year and ...
- Replies: 233
- Views: 83989
Re: 10070 - Leap Year or Not Leap Year and …
My code does provide all the sample output. but where it is wrong. code is
Code: Select all
//accepted