Feedback for LBCV217 problem

Learning course: Logic Building in C++
Problem Link: CodeChef: Practical coding for everyone

Feedback

// The code below is incorrect. Debug this code to solve the problem.

include
using namespace std;

int main() {
int x,y;
cin>>x>>y;

    int a=x/10;
            	cout << "a : " << a << endl;

    int b=y/10;
            	cout << "b : " << b << endl;

    if(x%10==0){
    	cout << "x : " << x << endl;
    	
    	cout << "a : " << a << endl;
        a=a-1;

    	cout << "after a : " << a << endl;
    }
    if(y%10==0){
    	cout << "y : " << y << endl;

    	cout << "b : " << b << endl;
        b=b-1;
    	cout << "after b : " << b << endl;

    }
            	cout << "a : " << a << endl;
    	cout << "b : " << b << endl;

    
    cout<<abs(a-b)<<endl;

}

@jayambe7
plzz refer the following solution for better understanding of the logic and implementation .

// Solution as follows

#include <iostream>
using namespace std;

int main() {
    int t;
    cin>>t;
    
    while(t--){
        int x,y;
        cin>>x>>y;
        
        int a=x/10;
        int b=y/10;
        if(x%10==0){
            // the floor correction was incorrect for room numbers divisible by 10
            a=a-1;
        }
        if(y%10==0){
            b=b-1;
        }
        
        // abs is missing. b Chefina can be on a higher or lower floor
        cout<<abs(a-b)<<endl;
    }
}