Pagini recente » Cod sursa (job #322284) | Cod sursa (job #2136519) | Cod sursa (job #92686) | Cod sursa (job #1463107) | Cod sursa (job #2110821)
#include <bits/stdc++.h>
#define CIFMAX 210
using namespace std;
short int n, a[CIFMAX], b[CIFMAX];
void add(short int t1[], short int t2[])
{
int i, t=0;
for(i=1; i<=t1[0] || t!=0; i++)
{
t2[i]=t2[i]+t1[i]+t;
t=t2[i]/10;
t2[i]%=10;
}
t2[0]=i-1;
}
int main()
{
freopen("nunta.in","r",stdin);
freopen("nunta.out","w",stdout);
scanf("%d",&n);
short int i;
a[1]=1, b[1]=2, a[0]=1, b[0]=1;
for(i=3; i<=n; i++)
if(i%2==1) add(b,a);
else add(a,b);
if(n%2==1)
{
for(i=a[0]; i>=1; i--)
printf("%d",a[i]);
}
else
{
for(i=b[0]; i>=1; i--)
printf("%d",b[i]);
}
return 0;
}