Cod sursa(job #1991243)

Utilizator gabrielamoldovanMoldovan Gabriela gabrielamoldovan Data 15 iunie 2017 20:46:10
Problema Algoritmul lui Euclid extins Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.59 kb
#include <iostream>
#include <fstream>

using namespace std;

ifstream f("euclid3.in");
ofstream g("euclid3.out");

void euclid(int a, int b, int *c, int *x, int *y)
{
    if(b == 0)
    {
        *c = a;
        *x = 1;
        *y = 0;
    }
    else
    {
        int x0, y0;
        euclid (b, a%b, c, &x0, &y0);
        *x = y0;
        *y = x0 - a/b *y0;
    }
}

int main()
{
    int t;
    while(t)
    {
        int a, b, c, x, y;
        f >> a >> b >> c;
        euclid(a, b, &c, &x, &y);
        g << x << " " << y << "\n";
        --t;
    }
    return 0;
}