Cod sursa(job #1647192)
Utilizator | Data | 10 martie 2016 19:23:35 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long putere(int x, int n)
{
while (n > 1)
{
x1 *= x2;
n--;
cout << x1 << " " << n << "\n";
}
return x1;
}
int main()
{
int x, n;
f >> x;
f >> n;
g << putere(x, x, n);
f.close();
g.close();
return 0;
}