Cod sursa(job #405234)
Utilizator | Data | 27 februarie 2010 19:39:13 | |
---|---|---|---|
Problema | Al k-lea termen Fibonacci | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.2 kb |
#include<fstream.h>
void main()
{int k,p,m=1.n=1,i=2;
ifstream f("kfib.in");
ofstream g("kfib.out");
f>>k;
if(k==0);
g<<0;
if((k==1)||(k==2)
g<<1;
while(i!=k)
{i++;
p=m+n;
m=n;
n=p;
}
g<<p;}