TP2
This commit is contained in:
28
TP2/2.2.cpp
Normal file
28
TP2/2.2.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int pow(int base, int exp);
|
||||
|
||||
void main()
|
||||
{
|
||||
int P1, P2, P3;
|
||||
|
||||
P1 = pow(5, 3);
|
||||
P2 = pow(7, 9);
|
||||
P3 = pow(3, 21);
|
||||
|
||||
cout << "\nLa puissance P1 est = " << P1;
|
||||
cout << "\nLa puissance P2 est = " << P2;
|
||||
cout << "\nLa puissance P2 est = " << P2;
|
||||
}
|
||||
|
||||
int pow(int base, int exp)
|
||||
{
|
||||
int r = 1;
|
||||
while (exp-- > 0)
|
||||
{
|
||||
r *= base;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
Reference in New Issue
Block a user