/* OIE 2001 - 1a fase */
/*
De picos pardos
Revision: 4/9/2001
*/
#include <stdio.h>
#include <stdlib.h>
#define ENTRADA "PIC.DAT"
#define SALIDA "PIC.RES"
int main()
{
FILE *FileIn,*FileOut;
int ant,pic,n,pos;
FileIn=fopen(ENTRADA,"r");
FileOut=fopen(SALIDA,"w");
if (FileIn==NULL | FileOut==NULL) exit(1);
while (fscanf(FileIn,"%d",&n)!=EOF)
{
for (ant=0,pic=0,pos=1; n!=0; fscanf(FileIn,"%d",&n),pos++)
{
if (ant==0) { ant=n; continue; }
if (n>ant) pic=1;
else if (n==ant) { if (pic) pic++; }
else if (pic)
{
if (pos-pic!=1) fprintf(FileOut,"%d %d\n",pos-pic,pic);
pic=0;
}
ant=n;
}
if (ant!=0) fprintf(FileOut,"***\n");
}
return 0;
}
|