|
|
back to boardWHY WA 4 . please help me !!!!!!!! I submissions 14 time this is my code #include<stdio.h> int main() { char str0[100]; int str1[100],str2[100],str3[100]; int i,len=0; gets(str0); for(i=0;str0[i]!='\0';i++,len++) str1[i]=str0[i]-'a';
str2[0]=str1[0]; for(i=1;i<len;i++) { str2[i]=str1[i]; while(str2[i]<str2[i-1]) { str2[i]+=26;
} }
str3[0]=str2[0]-5; for(i=0;i<len;i++) str3[i+1]=str2[i+1]-str2[i];
for(i=0;i<len;i++) printf("%c",(str3[i]%26)+'a');
} Edited by author 28.11.2006 22:06 Edited by author 28.11.2006 22:08 Re: WHY WA 4 . Posted by Asmund 29 Oct 2006 12:52 not (a[0] in ['a'..'z'])!! Re: WHY WA 4 . Posted by lbc 16 Nov 2006 14:35 What I wanna tell you is that this problem is really easy to solve. You only need to have a really good thinking. Try to find the changes between each letters or numbers. Then you'll work it out! Re: WHY WA 4 . The problem is that you haven't considered the case where str[0]<'a'+5. In this case when you do str[0]-=5 at the end a value lesser than 'a' may be obtained. Hence at the end if (str[0]-=5)<0 then str[0]+=26. Try this test case once bimdhhycaoinese Answer should be whereareyoufrom you get [hereareyoufrom if you havent taken care of the condition. Re: WHY WA 4 . Posted by Helberg 31 Dec 2012 01:23 <<jagatsastry>> A lot of Thanks)) Re: WHY WA 4 . <jagatsastry> Thank you very much for explanation Re: WHY WA 4 . <jagatsastry> Thank you very much for explanation |
|
|