-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcapu_calc.cpp
executable file
·56 lines (46 loc) · 1.02 KB
/
capu_calc.cpp
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
#include <iostream>
using namespace std;
int main()
{
int debut(0);
do
{
cout << "de (>= 1) ? ";
cin >> debut;
} while (debut < 1);
int fin(0);
do
{
cout << "a (>= " << debut << ") ? ";
cin >> fin;
} while (fin < debut);
/*******************************************
* Completez le programme a partir d'ici.
*******************************************/
for (int i(debut); i <= fin; ++i)
{
int n = i;
int k = 0;
do
{
if (n % 3 == 0)
{
n = n + 4;
}
else if (n % 4 == 0)
{
n = n / 2;
}
else
{
n = n - 1;
}
k = k + 1;
} while (n > 0);
cout << i << " -> " << k << endl;
}
/*******************************************
* Ne rien modifier apres cette ligne.
*******************************************/
return 0;
}