Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 question help
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
saltpro15




PostPosted: 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;
}
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: 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;
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
saltpro15




PostPosted: Mon Mar 02, 2009 5:57 pm   Post subject: RE:question help

ah, I get it, thanks Tony
saltpro15




PostPosted: 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
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: