Cod sursa(job #330305)

Utilizator LuffyBanu Lavinia Luffy Data 9 iulie 2009 15:02:09
Problema Koba Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.49 kb
#include<stdio.h>
using namespace std;
int calcul(int n, int t1, int t2, int t3)
{int t4;
int suma;
 n=n-3; suma=t1%10+t2%10+t3%10;
  while(n>0)
 {t1=t1%10; t2=t2%10; t3=t3%10;
  t4=(t3+t2*t1)%10;
  t1=t2; t2=t3; t3=t4; t4=0;
  suma=suma+t3;
  n--;}
return suma;
}
  
	
int main()
{int n;
int t1,t2,t3;
 FILE *f=fopen("koba.in","r"), *g=fopen("koba.out","w");
 fscanf(f,"%d%d%d%d",&n,&t1,&t2,&t3);
 fprintf(g,"%d\n",calcul(n,t1,t2,t3));
fclose(f);
fclose(g);
return 0;
}