1. ## three

Hello guys!

I've tried to solve the next problem:
For a sequence of natural numbers n you must establish the maximum number of elements of the sequence whose sum divides 3 and the items that don't belong the sum.
So,I need a variable n(for the number of numbers that will be read),nr(for the number I read at the current step),i,s3(that is initially 0) and a counter that counts the maximum items of the sequence whose sum divides 3.
How should I do it?
Code:
int n,i,nr,s3 = 0,k3 = 1;
cin >>  n;
for (i = 1;i <= n;i++) {
cin >> nr;
s = s+nr;
if (s % 3 == 0) break; // What should I do here ??
}

2. First of all I will recommend in the future to use more explanatory title.
Second, the problem is much more difficult than you are trying to solve in the code.
e.g. lets say n=10, then your solution doesn't take into consideration the 1,3,4,7 solution because you don't allow skipping numbers.
This is valid only if I understood the problem.
I believe it should at least be loop inside loop.
And you probably need some data structure to hold the current used inumbers.

3. I'm nominating this thread for the "worst thread title of the year" award.

4. Originally Posted by Elkvis
I'm nominating this thread for the "worst thread title of the year" award.
I am sorry to disappoint you but this is not the title I chose for the problem.I found this problem in a book a couple of weeks ago and this was its name 'three'.What is so wrong with it? Maybe it doesn't say much about the problem but I kept the name without realising when I wrote the thread.
Next time I will try to give my threads better titles so you all can understand...

5. The title should describe what the topic of the thread is about.
More suited names might have been "I need help with this algorithm" or "help with natural number algorithm," etc.