I tried some custom input and then I figured out that whenever there is βtβ in string it produces wrong output.
link to code
One test case going wrong
@tanjuljain19 hey, apka code two character string pr work nhi krrha ,apko two character string ka case alag se handle krna pdega else you can simply use difference here is pseudo code:
#include
#include
using namespace std;
int main() {
char str[1000];
int nstr[2000];
cin>>str;
int i=1;
cout<<str[0];
while(str[i]!=β\0β){
nstr[i]=int(str[i])-int(str[i-1]);
cout<<nstr[i]<<str[i];
i++;
}
return 0;
}
https://ide.codingblocks.com/s/210666 I made the changes for 2 character but one test case id still wrong. Whenever there is βtβ alphabet in string its producing wrong output. For ex-for string βatβ it produces wrong output
@tanjuljain19 hey apko two length wala case alag se lena hai ,its not depend on t ,koi bhi 2 wale pr nhi chlnrha ye.
I hope Iβve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
@tanjuljain19 actually the problem arises as soon as the difference becomes a 2 digit number. Now, when you add a 2 digit number to β0β it doesnβt match to the ascii values of 0-9. You can consider using the to_string function here instead. https://ide.codingblocks.com/s/219862 I have made approriate changes to your code here.