Pagini recente » Cod sursa (job #2430664) | Cod sursa (job #1034092) | Cod sursa (job #2366566) | Cod sursa (job #3344343) | Cod sursa (job #3356714)
#include <stdio.h>
float exp_log(float x, int n) {
if (n < 0) {
x = 1./x;
n = -n;
}
if (n == 0)
return 1;
float p = 1;
while(n > 0) {
if(n % 2 == 1) {
p = p * x;
}
x = x * x;
n /= 2;
}
return p;
}
int main() {
FILE *fin = NULL;
fin = fopen("lgput.in", "r");
if(fin == NULL)
return -1;
float n;
int p;
fscanf(fin, "%f %d", &n, &p);
FILE *fout = NULL;
fout = fopen("lgput.out", "w");
fprintf(fout, "%f", exp_log(n, p));
fclose(fin);
fclose(fout);
return 0;
}