MY TEST CASE 2 IS NOT PASSED
REPLACE THEM ALL
testcase failed because you miss one corner case
what if input is
n = 0
then in that case your output will be 0 but correct output is 5
i hope you understand this point
and also
this portion of your code is useless, i didn’t understand why you have done this
long long int total = 0;
while (sum)
{
int a = 0;
a = sum % 10;
sum = sum / 10;
total = (total * 10) + a;
}
cout << total;
if you didn’t understand feel free to ask
what i am doing is like i am seeing the digits from back and restoring it in a variable so the digit is reversed and now i want to print that in the form which is required that is reason i have applied second loop
see the code which i have one now which is for one zero only and it ran all test cases
you can do it like this
long long int sum = 0;
int pv = 1;
while (n)
{
int d;
d = n % 10;
n = n / 10;
if (d == 0)
{
d = 5;
}
sum = sum + d * pv;
pv = pv * 10;
}
can u explain this code
your latest code is for all input
yes now it runs all testcases
check your chatbox i have shared a link with you
have you got the link??
no
i didn’t got the link
link for what and why??
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.
i have a problem with test case 1. please help.