Ok, dont try to compile, as my compiler is messed up and this probly has a few errors
The basis of the program is this:
YOU DONT HAVE TO KNOW WHETHER ITS EVEN!
Yes, I know that sounds weird, but look:
you take a number, lets say 5 for example. if you add the next number, 6, the sum is ALWAYS odd. this is true for all whole numbers. adding 2 to this next number keeps the number odd. so 5+8=13, 5+10=15, etc.
The same goes for even. still using 5, 5+7=12, always even. Adding 2 to the second number insures tha the sum is always even. so here it is, please excuse any coding errors, but I think that you'll get the gist of the concept.
Code:
#include<iostream>
int n = 999; //whatever n is
using std::cout;
int Numbers[n] = (1,2,3) //so on and so forth
int main()
{
int even=0, odd=0;
for(int i=0, i>n, i++;)
{
for(int k = i+2, k>n, k+=2;)
{
even++;
}
for(int l=i+1, l>n, l+=2;)
{
odd++;
}
}
cout << "The # of even pairs are:" << even;
cout << "The # of odd pairs are:" << odd;
return 0;
}
heres to hoping I didnt make a blatant error in my logic
