Pagini recente » Citylog | Cod sursa (job #1247884) | Cod sursa (job #1464432) | Cod sursa (job #3154085) | Cod sursa (job #356471)
Cod sursa(job #356471)
Utilizator |
Marian S eu93 |
Data |
14 octombrie 2009 21:13:18 |
Problema |
Nunta |
Scor |
40 |
Compilator |
cpp |
Status |
done |
Runda |
CNRV #2 |
Marime |
0.32 kb |
#include <fstream.h>
int main ()
{ int n,a,b,c,i,k;
ifstream f("nunta.in");
ofstream g("nunta.out");
f>>n;
if (n==1) g <<"1";
else if (n==2) g <<"1";
else { a=1; b=2;
for (i=3;i<=n;i++) {
c=a+b;
a=b;
b=c;
}
g<<c;
}
f.close();
g.close();
}