I am trying to solve decreasing string problem http://www.codechef.com/problems/DECSTR I have wrote the following code
#include<stdio.h>
int main(void)
{
int t,k,i;
scanf("%d",&t);
while(t--)
{
scanf("%d",&k);
for(i=0;i<=k;i++)
{
printf("%c", (97+k)-i);
}
printf("\n");
}
return 0;
}
I have complied and runned it successfully on codechef ide and shows correct o/p for testcases. However when i submit the code it shows wrong answer I dont really understand whats the error can someone please tell me whats lacking?
your code is not printing anything! check here
@rishabprsd7 thanks for replying i added getchar() still its not working check it doesn’t print anything http://ideone.com/dd0xZ5
@rjohari23 anything i can do to print data i tried myself but its not printing for your testcases but as per problems test cases its working now
Thats really strange… Dont know why ideone is not giving any output whereas in codeblocks output is printed.
@rishabhprsd7 if k=100 then 97+k-i greater than the ASCII code of z that’s why u are getting those symbols
@sam_coder13 you should consider cases when k>=26.