Need help with this C program Plz dont use java Thanks The P
Need help with this C++ program. Plz dont use java. Thanks
The Pulverizer or the Extended Euclidean algorithm. This method should ask the user for two integers ( a and b ) and compute the values of s, t and gcd(a,b) in the following equation: gcd(a,b) = sa+ tb
Solution
#include <iostream>
 using namespace std;
int main()
 {
    int s1,s2,t1,t2,q,r1,r2;
    cout<<\"Enter two numbers:\";
    cin >> r1;
    cin >> r2;
    s1=1;s2 = 0;
    t1=0; t2=1;
    int tmp1,tmp2;
    while(r2>0)
    {
        q = r1/r2;
        tmp1 = r1%r2;
        r1 = r2;
        r2 = tmp1;
       tmp1 = s1 - q*s2;
        s1 = s2;
        s2 = tmp1;
       tmp1 = t1 - q*t2;
        t1=t2;
        t2 = tmp1;
    }
    cout<<s1<<\" \"<<t1<<endl;
    return 0;
 }

