I believe that my solution to the Q FLOW004 of the Beginner problems.
My code
#include <iostream>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t, n, f, i=8;
cin>>t;
while(t--){
cin>>n;
f=n;
while(i--){
if(f/10==0){ goto pit;}
else {f/=10;}
}
pit: cout<<(f+n%10)<<'\n';
i=8;
}
return 0;
}
I think it is correct as it does give me correct outputs with custom inputs, but I am just not able to figure out why it is still giving me a runtime error.
Pls, help me figure this out and understand the case where the inputs make it give an error.
Thank you!
Yes, I was just trying to run it and check if it had any problems before submitting it.
I mean, if it shows an error while running it, then why would I submit it.
Also, it does give me correct results with custom inputs.
Should I still, anyway, just submit it and see if it gives me an error or wrong answer?
I think your all test cases are not cleared that’s why you are getting the wrong answer. you yourself have to clear the test cases.
my set of code for problem FLOW004 ; all cases clear
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t,no,ldigit,sum;
cin>>t;
while(t>0)
{
cin>>no;
ldigit = no % 10;
while(no>=10)
{
no = no/10;
}
sum = ldigit + no;
cout<<sum<<endl;
t--;
}
}