Computer Science Canada

question help

Author:  saltpro15 [ Mon Mar 02, 2009 5:26 pm ]
Post subject:  question help

So I'm working on this question out of boredom, and I seem to be braindead today, because for the life of me I cannot get this to work Sad
https://www.spoj.pl/problems/SIZECON/

here is what I have so far

*note the fstreams are just for my notes, they aren't actually part of the question
AND BEFORE ANYONE ASKS: I use Bluefish as an editor and compile with g++

c++:

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

int main() {
ifstream fin ("SIZEIN.txt");
ofstream fout ("OUT.txt");
int num;
int input;
int newinput;
int newnewinput;
fin >> num;
for (int a = 0; a < num; a++) {
fin >> input;
if (input > 0) {
newinput = input;
newnewinput = newinput + input;
}
}
fout << newnewinput;
return 0;
}

Author:  Tony [ Mon Mar 02, 2009 5:38 pm ]
Post subject:  RE:question help

I see the problem. Here's a hint:
Quote:

int input;
int newinput;
int newnewinput;

Author:  saltpro15 [ Mon Mar 02, 2009 5:57 pm ]
Post subject:  RE:question help

ah, I get it, thanks Tony

Author:  saltpro15 [ Mon Mar 02, 2009 6:34 pm ]
Post subject:  RE:question help

got it Smile can a mod do me a favor and delete this? it doesn't seem too necessary


: