Problem: Grab a ladder.

http://www.codechef.com/ICD2015/problems/ICD02

#include <stdio.h>

#include <stdlib.h>

int *c1;

int main()

{

int i=0,j=0,cases=0,n=0,ladder=0,h=0;

FILE *fp;

FILE *fp1;

```
fp=fopen("test.txt", "r");
fp1=fopen("out.txt", "w");
fscanf(fp,"%d",&cases);
for(i=0; i<cases; i++)
{
ladder=0;
fscanf(fp,"%d",&n);
c1 =malloc(n*sizeof(int));
for(j=0;j<n;j++)
{
fscanf(fp,"%d",&c1[j]);
}
h=c1[0];
for(j=0;j<n-1;j++)
{
if(c1[j]<c1[j+1])
{
if(c1[j+1]>h)
{
h=c1[j+1];
ladder++;
}
}
}
fprintf(fp1,"%d ",ladder);
}
fclose(fp);
free(c1);
return 0;
```

}