Social Icons

Thursday, May 21, 2015

Solution of 1234 number problem with C,, in Uri Online Judge

Problem link :
   
                https://www.urionlinejudge.com.br/judge/en/problems/view/1234

Solution :


   #include <stdio.h>
 #include <string.h>


int main()
{
    char str[1000],str1[1000];
    int i,j,k,l,n,m;
    while(gets(str) != NULL)
    {
        k = strlen(str);
        n=0;
        for (i=0;i<k;i++)
        {
           if(str[i] != ' ')
           {
               n++;
               if(n%2 != 0)
               {
                   if(str[i]>='a' && str[i]<= 'z')
                    str[i] = str[i] - 32;
                   else
                    str[i] = str[i];
               }
               else
               {
                    if(str[i]>='A' && str[i]<= 'Z')
                    str[i] = str[i] + 32;
                   else
                    str[i] = str[i];
               }
           }
        }
        printf("%s\n",str);
    }
}

1 comments: