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 1493. One Step from Happiness

what's wrong
Posted by dheman 26 Feb 2010 02:16
my code is
#include<stdio.h>
#include<string.h>
int main()
{
    char a[10];
    while(scanf("%s",a)==1)
    {
        long int s1=0,s2=0;
        long int len = strlen(a);
        for(long int i=0;i<len;i++)
        {
            if(i<3)
                s1 = s1 + (a[i]-'0');
            else
                s2 = s2 + (a[i] - '0');
        }
        long int sub = s1 - s2;

        if(sub ==1 || sub== -1)
        {
            if(sub==1)
            {
                long int add = (a[len-1]-'0')+1;
                if(add>9)
                {
                    printf("No\n");
                }
                else
                printf("Yes\n");
            }
            else if(sub == -1)
            {
                if(a[len-1]<1)
                printf("No\n");
                else
                printf("Yes\n");
            }
        }
        else
            printf("No\n");
    }
    return 0;
}

i don't know where is my problem. please help me.
Re: what's wrong
Posted by tanmoy chowdhury 26 Feb 2010 02:47
opps. sorry .. i found my mistake..