#include <conio.h>
using namespace std;
class pretest{
friend istream& operator>>(istream&, pretest&);
friend ostream& operator<<(ostream&, pretest&);
public:
int rekursif(int i, int b);
int literatif(int j, int k);
private:
int x,y;
};
int pretest::rekursif (int i,int b){
if (i>=b)
{
if (i % 2==0)
{
cout << i <<" "; }
else
{ }
}
else
{
if (i % 2==0)
{
cout << i <<" ";
return rekursif(i+3,b);
}
else
{
return rekursif(i+3,b);
}
}
};
int pretest::literatif (int j,int k)
{
while (!(j>=k))
{
if (j % 2==0)
{
cout << j <<" "; }
else
{ }
j =j+3;
}
if (j % 2==0)
{
cout << j <<" "; }
else
{ }
};
istream& operator>>(istream& in, pretest& input){
cout<<"menghitung nilai genap dengan beda 3";
cout<<"\n\nMasukkan awal : ";
in>>input.x;
cout<<"Masukkan batas : ";
in>>input.y;
};
ostream&operator<<(ostream& out, pretest& output){
cout << "\n\nSecara Literatif = ";
output.literatif(output.x,output.y);
cout << "\n\nSecara rekursif = ";
output.rekursif(output.x, output.y);
};
int main()
{ pretest v;
cin>>v;
cout<<v;
getch();
}