Mai intai trebuie sa te autentifici.
Cod sursa(job #1564432)
| Utilizator | Data | 9 ianuarie 2016 17:56:18 | |
|---|---|---|---|
| Problema | Nunta | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.65 kb |
#include <stdio.h>
using namespace std;
FILE*f=fopen("nunta.in","r");
void suma(int f1[],int f2[],int f3[]){
int i=1,z=0,x;
while (i<=f1[0]||i<=f2[0]||z>0){
x=f1[i]+f2[i]+z;
f3[i]=x%10;
z=x/10;
i++;
}
f3[0]=i-1;
}
int main()
{
int f1[1001]={1,1},f2[1001]={1,1},f3[1001]={0},n,i;
fscanf(f,"%hd",&n);
fclose(f);
FILE*f=fopen("nunta.out","w");
while(n){
suma(f1,f2,f3);
for (i=1;i<=f2[0];i++) f1[i]=f2[i];
for (i=1;i<=f2[0];i++) f2[i]=f3[i];
n--;
}
for (i=f1[0];i>=1;i--) fprintf(f,"%hd",f1[i]);
fclose(f);
return 0;
}
