can someone help me out with
this:
i've got a little snippet
that supposedly should use vectors
to read values from user, then
display the data in assending and descending
order in which they were entered,
thereafter it should display
the even and odd numbers among the
date entered.
i've tried to an extent but here's what
i've got so far:

#include<iostream>
#include<vector>
#include<iomanip>
using namespace std;



void print(const vector<int>&);
void print_backwards(const vector<int>&);
void findevenandodd(const vector<int>&);



int main()
{
vector<int> v;
int number;
cout <<"Input some numbers and then end the input\n";
while(cin>>number){
v.push_back(number);
}//end while
print(v);
print_backwards(v);
findevenandodd(v);
}//main


//Finally the two procedures that print out the data:


void print_backwards( const vector<int> &a)
{
int even = 0;
for(int i=a.size()-1; i>=0; --i)
cout << a << " ";
cout << endl;
cout<<endl;
}//print_backwards


void print(const vector<int>& a)
{
for(size_t i=0; i<a.size(); ++i)
cout << a << " ";
cout << endl;
cout <<endl;
}//print


void findevenandodd(const vector<int> &osagie)
{
//here's where i have problems
//am totally confused here nd
//don't Know what to do


cout << "even numbers are:"
int even = 0;
for(size_t i=1; i<=osagie.size(); ++i){
if(osagie.size()==even){
even=osagie.size();
even=even+2;
}
}
//please i'll be most greatful
//to anyone who'll work it out
//for me neatly.


}

Edited 3 Years Ago by pritaeas: Fixed formatting

This should get you started.

void printEvenAndOddSeperately(vector<int>& v)
{
    for(int i = 0; i < v.size(); i++)
     {
             if( v[i] % 2 == 0) cout << v[i] << " is even\n";
             else cout << v[i] << " is odd\n";
      }
}

Edited 7 Years Ago by firstPerson: n/a

This article has been dead for over six months. Start a new discussion instead.