top of page

Практикум по программированию на языке С,
Вычислительная физика, Теория алгоритмов.
ФНБИК МФТИ
2015-2016 учебный год
1 #include <stdio.h>
2 #include <math.h>
3 int power(int m, int n); /* in declaration m and n can be absent */
4 int main (void){
5
6 int i, res1, res2;
7 for(i=0;i<10; i++){
8 res1=power(2,i);
9 res2=power(-3,i);
10 printf("%d %d %d\n", i, res1, res2);
11 }
12 return 0;
13 }
14
15 int power(int base,int n){
16 int i,p;
17 p=1;
18 for(i=1;i<=n; i++)
19 p=p*base;
20 return p;
21 }
bottom of page