1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
   | #include <iostream>
using namespace std;
 
int p (int n, int j)
{
	j=n/2;
	return j;
}
 
int i (int n, int j)
{
	j=3*n+1;
	return j;
}
 
bool r (int n, int j)
{
	j=n%2;
	if (j==0)
	{
		return true;
	}
	else 
	{
		return false;
	}
}
 
 
void syrac (int n, int j) 
{
	bool k;
 
 
	while (n!=1)
	{
 
	k=r(n,j);
	cout << n << " ";
		if (k==true)
			n=p(n,j);
		else
			n=i(n,j);
 
	}
 
 
}
 
int main ()
{
	int n;
	int j;
 
 
	cout << "Entrez un entier positif : " << endl;
	cin >> n;
	cout << "Vol" << n << " -> ";
	syrac(n,j);
	cout << "1" << endl;
 
	system("PAUSE");
	return 0;
} |