/* merge plików */
#include<stdio.h>
main()
{
int l,r;
FILE *fpl,*fpm,*fpr;
fpl=fopen("danel","r");
fpm=fopen("danem","w");
fpr=fopen("daner","r");
fscanf(fpl,"%d",&l);
fscanf(fpr,"%d",&r);
while(!feof(fpl)&&!feof(fpr))
{if(l<r)
{fprintf(fpm,"%d ",l);fscanf(fpl,"%d",&l);}
else
{fprintf(fpm,"%d ",r);fscanf(fpr,"%d",&r);};
}
if(l<r)
{fprintf(fpm,"%d ",l);fprintf(fpm,"%d ",r);}
else
{fprintf(fpm,"%d ",r);fprintf(fpm,"%d ",l);};
while(!feof(fpl))
{fscanf(fpl,"%d",&l);fprintf(fpm,"%d ",l);}
while(!feof(fpr))
{fscanf(fpr,"%d",&r);fprintf(fpm,"%d ",r);}
fclose(fpl);
fclose(fpm);
fclose(fpr);
}