ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1581. Teamwork

wa1 why??
heres my code
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int *a;
int  count(char *s)
{
    int i=0,j=0;
    while(!(s[i]>='0' && s[i]<='9'))
        i++;
    while(s[i])
    {
        if(s[i]>='0' && s[i]<='9')
        {
            if(i==0 || !(s[i-1]>='0'&& s[i-1]<='9'))
                j++;
        }
        i++;
    }
    return j;
}


int main(void)
{
    int l,n,num=0,k=0,i=0,x,y,countspace=0,j=0;
    char c,s[10000]="",c1=0;
    char s1[500];
    scanf("%d",&n);
    a=(int*)malloc((k+1)*sizeof(int));
    fflush(stdin);
    while(j<n)
    {
        fgets(s1,sizeof(s1)-1,stdin);
        s1[strlen(s1)-1]=0;
        j+=count(s1);
        strcat(s,s1);
    }
    l=strlen(s);
    i=0;
    do{
            if(i>=l)
                break;
            c=s[i++];
            if(c>='0' && c<='9')
                num=num*10+c-'0';
            else
            {
                if(c==' ')
                {
                    if((c1>='0' && c1<='9'))
                        countspace++;
                }
                if(num>0)
                        a[k++]=num;
                num=0;
                if(countspace==n-1)
                    break;
            }
            c1=c;
        }while(1);
    while(1)
    {
           if(i>=l)
                break;
            c=s[i++];
            if(c>='0' && c<='9')
                break;
    }
    while(c>='0' && c<='9')
    {
                num=num*10+c-'0';
                if(i>=l)
                    break;
                c=s[i++];
    }
    a[k]=num;
    for(i=0;i<=k;)
    {
        x=a[i];
        y=0;
        while(a[i]==x && i<=k)
        {
            y++;
            i++;
        }
        if(i<=k)
            printf("%d %d ",y,a[i-1]);
        else
            printf("%d %d",y,a[i-1]);
     }
     return 0;
}
please help with some test cases.