Intelligent Girl : HackerEarth Problem Solution

Intelligent Girl : HackerEarth Problem Solution


Implementation:

#include <stdio.h>
#include <stdlib.h>
int main()
{
    char *s;
    int i,even=0,hash[10]={0};
    s=(char*)malloc(sizeof(char)*10000);
    scanf("%s",s);
    i=0;
    while(*(s+i))
    {
     if(!((*(s+i)-'0')&1))
      {
       even++;
       hash[*(s+i)-'0']=1;
      }
      i++;
    }
    i=0;
    while(*(s+i))
    {
     //if(!((*(s+i)-'0')&1))
     if(hash[*(s+i)-'0']==0)
      printf("%d ",even);
     else
     {
      printf("%d ",even);
      even--;
     }
     i++;
    }
    return 0;
}