Pagini recente » Cod sursa (job #1691942) | Cod sursa (job #1324406) | Cod sursa (job #1254298) | Cod sursa (job #1909156) | Cod sursa (job #497319)
Cod sursa(job #497319)
#include <stdio.h>
FILE *f,*s;
long int z;
void Rezolva(long int k,long int x,long int y)
{
if(k==0) return;
int l=(1<<(k-1));
if(x<=l && y<=l) Rezolva(k-1,y,x);
if(x>l && y<=l) { z+=l*l; Rezolva(k-1,x-l,y); }
if(x>l && y>l) { z+=2*l*l; Rezolva(k-1,x-l,y-l); }
if(x<=l && y>l) { z+=3*l*l; Rezolva(k-1,2*l-y+1,l-x+1); }
}
int main()
{
long int k,x,y;
f=fopen("fractal.in","r");
s=fopen("fractal.out","w");
fscanf(f,"%ld %ld %ld",&k,&x,&y);
Rezolva(k,y,x);
fprintf(s,"%ld",z);
fclose(s);
return 0;
}