help for bugcal

my code partially solved but not fully please tell on which test it went wrong
I have tested 10001 90009 answer 0 mine . AND THE PASTED CODE HERE IS SHOWING SOME FOOL THINGS WHICH I DONOT HAVE IN MY CODE I PASTED IT HERE AND IT GET BAD LIKE #INCLUDE AND PLEASE UPVOTE SO I CAN ABLE TO UPLOAD CODE HERE

    #include <bits/stdc++.h>
    #define ll long long
    #define fast ios_base::sync_with_stdio(0)

     using namespace std;

      int main() {

fast;

ll t;
cin >> t;

while( t-- )
{
    ll num1 , num2 ;
    cin >> num1 >> num2 ;
    vector<int> v;
    int sum;
    while( num1 != 0 || num2 != 0 )
    {
        int r1 = num1 % 10;
        int r2 = num2 % 10;
        sum = r1+ r2;
        v.push_back(sum%10);
        num1 /= 10;
        num2 /= 10;
    }
    sum = 0;
    for( int i=0; i<v.size(); i++)
      {
        sum += v[i];
      }

    if( sum != 0 )
    {
        for( int i= v.size()-1; i>=0; i--)
            cout << v[i];
    }
    else
   {
        cout << 0;
    }
    cout << endl;
}
return 0;
}

Mate, Following test case fails your solution

1

55 54

Correct answer = 9

Your answer = 09

Refer https://discuss.codechef.com/questions/115538/october-lunchtime-unofficial-editorials-first-two-problems if you feel any need :slight_smile:

Why are you taking the sum? There is no need of it. You can just print all the digits one by one.

remove leading zeros ‘0’ or if all value is zero the print only one zero ‘0’ if got the same problem

2

54 54

55 55

output

8

0

my code link CodeChef: Practical coding for everyone

solution link
https://www.codechef.com/viewsolution/15994012

for leading zeros

thanks taran

That’s where the trouble is. :smiley:

No problem.