You are not logged in. Please login at www.codechef.com to post your questions!

×

problem code::SCHAR...WA but getting correct at my side

i have tested the programme many times on my compiler it is giving AC but on codechef it is showing WA .. please help if there are any errors or improvements

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

int main() {

int t; char str[100000+1]; long len;
unsigned long sum=0;

scanf("%d",&t);
while(t--)
{
    scanf("%s",str);
    len=strlen(str);

    for(long i=0;i<len;i++)
    { int diff=(int)str[i]-(int)str[i+1];

     sum+=abs(diff);
    if(str[len-1]==str[i+1])
    {
         break;
        }   
    }


printf("%ul\n",sum);    
}
return 0;

}

asked 31 Aug '17, 13:55

sachin_123yad's gravatar image

2★sachin_123yad
03
accept rate: 0%


your logic is not correct

link

answered 31 Aug '17, 15:34

new_naveen602's gravatar image

3★new_naveen602
1
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×2,539
×1,019
×189
×2
×1

question asked: 31 Aug '17, 13:55

question was seen: 134 times

last updated: 31 Aug '17, 15:34