Thursday, 6 April 2017

Geeksforgeeks Solution For " Subtraction and two numbers "

GeeksforGeeks Solution For Hard Domain .Below You Can Find The Solution Of  School Basic ,Easy ,Medium . Or Hackerrank Solution You Can Also Direct Submit Your Solution to Geeksforgeeks Same Problem .You Need to login then you can submit you answers 

Problem :- Subtraction and two numbers

Submit Your Solution :- Click Here 

Solution :- 

#include<iostream>
using namespace std;
int main()
 {
int t,a,b,max,min,r,c,count;
    cin>>t;
        
    while(t--)
    {
        cin>>a>>b;
        
        if(a>b)
        {
            max=a;
            min=b;
        }
        else
        {
            max=b;
            min=a;
        }
        count=0;
        if(max%min==0)
        {
            cout<<max/min;
        }
        else
        {
            r=max%min;
            while(r!=0)
            {
                c=max/min;
                count=count+c;
                r=max%min;
                max=min;
                min=r;
            }
            cout<<count;
        }
        cout<<"\n";   
    }     
}

Output:-



Geeksforgeeks Solution For " Subtraction and two numbers "

No comments:
Write comments

Recommended Posts × +