Here you will find solutions of many problems on spoj. If you want solution of some problem which is not listed in blog or have doubt regarding any spoj problem (which i have solved) or any programming concept (data structure) you can mail me @ raj.nishant360@gmail.com

And my humble request to you all that don't copy the code only try to understand the logic and algorithm behind the code. I have started this because if you tried as hard as you can and still can't find any solution to the problem then you can refer to this.
You can read my answer how to start competitive programming CLICK HERE

Sunday, December 15, 2013

BANDW - Black and White

Below given c++ code is for bandw spoj or black and white spoj.
#include<bits/stdc++.h>
int main()
{
   while(1)
   {
      char *S,*T;
      S=(char *)malloc(501*sizeof(char));
      T=(char *)malloc(501*sizeof(char));
      scanf("%s%s",S,T);
      if(S[0]=='*' && T[0]=='*')
         break;
      int i=0,count=0;
      while(S[i]!='\0')
      {
         if(S[i]!=T[i])
         {
            count++;
            while(S[i]!=T[i])
            i++;
         }
         i++;
      }
      printf("%d\n",count);
   }
   return 0;
}

No comments:

Post a Comment

Your comment is valuable to us