#include <stdio.h>
void bunsa(int *, int *, int *, int * , int * , int * );
void bunsyo(int *, int *, int *, int * , int * , int * );
void yakubun(int *, int *);
int main()
{
int x1, x2, y1, y2, a1, a2, b1, b2;
bunsa(&x1, &x2, &y1, &y2, &a1, &a2);
yakubun(&a1, &a2);
bunsyo(&x1, &x2, &y1, &y2, &b1, &b2);
yakubun(&b1, &b2);
printf(" %d / %d - %d / %d = %d / %d \n", x1
, x2
, y1
, y2
, a1
, a2
); printf(" %d / %d ÷ %d / %d = %d / %d \n", x1
, x2
, y1
, y2
, b1
, b2
); return 0;
}
void bunsa( int *x1, int *x2, int *y1, int *y2, int *a1, int *a2)
{
*a1 = *x1 * *y2 - *x2 * *y1;
*a2 = *x2 * *y2;
}
void bunsyo( int *x1, int *x2, int *y1, int *y2, int *b1, int *b2)
{
*b1 = *x1 **y2;
*b2 = *x2 **y1;
}
void yakubun( int *n1, int *n2)
{
int w1 = *n1;
int w2 = *n2;
int t;
if (w1 < 0)w1 *= -1;
if (w2 < 0)w2 *= -1;
while (w1 * w2)
{
w1 %= w2;
t = w1; w1 = w2; w2 = t;
}
*n1 /= w1;
*n2 /= w1;
}
I2luY2x1ZGUgPHN0ZGlvLmg+Cgp2b2lkIGJ1bnNhKGludCAqLCBpbnQgKiwgaW50ICosIGludCAqICwgaW50ICogLCBpbnQgKiAgICk7CnZvaWQgYnVuc3lvKGludCAqLCBpbnQgKiwgaW50ICosIGludCAqICwgaW50ICogLCBpbnQgKiAgICk7CnZvaWQgeWFrdWJ1bihpbnQgKiwgaW50ICopOwoKaW50IG1haW4oKQp7CiAgICBpbnQgeDEsIHgyLCB5MSwgeTIsIGExLCBhMiwgYjEsIGIyOwoKICAgIHByaW50Zigi5YiG5pWwMeOBruWIhuWtkOOCkuWFpeWKm+OBl+OBpuOBj+OBoOOBleOBhO+8miIpOwogICAgc2NhbmYoIiVkIiwgJngxKTsKICAgIHByaW50Zigi5YiG5pWwMeOBruWIhuavjeOCkuWFpeWKm+OBl+OBpuOBj+OBoOOBleOBhO+8miIpOwogICAgc2NhbmYoIiVkIiwgJngyKTsKICAgIHByaW50Zigi5YiG5pWwMuOBruWIhuWtkOOCkuWFpeWKm+OBl+OBpuOBj+OBoOOBleOBhO+8miIpOwogICAgc2NhbmYoIiVkIiwgJnkxKTsKICAgIHByaW50Zigi5YiG5pWwMuOBruWIhuavjeOCkuWFpeWKm+OBl+OBpuOBj+OBoOOBleOBhO+8miIpOwogICAgc2NhbmYoIiVkIiwgJnkyKTsKCiAgICBidW5zYSgmeDEsICZ4MiwgJnkxLCAmeTIsICZhMSwgJmEyKTsKICAgIHlha3VidW4oJmExLCAmYTIpOwoKICAgIGJ1bnN5bygmeDEsICZ4MiwgJnkxLCAmeTIsICZiMSwgJmIyKTsKICAgIHlha3VidW4oJmIxLCAmYjIpOwoKICAgIHByaW50ZigiICVkIC8gJWQg77yNICVkIC8gJWQgPSAlZCAvICVkIFxuIiwgeDEsIHgyLCB5MSwgeTIsIGExLCBhMik7CiAgICBwcmludGYoIiAlZCAvICVkIMO3ICVkIC8gJWQgPSAlZCAvICVkIFxuIiwgeDEsIHgyLCB5MSwgeTIsIGIxLCBiMik7CiAgICByZXR1cm4gMDsKfQoKdm9pZCBidW5zYSggaW50ICp4MSwgaW50ICp4MiwgaW50ICp5MSwgaW50ICp5MiwgaW50ICphMSwgaW50ICphMikKewogICAgKmExID0gKngxICogKnkyIC0gKngyICogKnkxOwogICAgKmEyID0gKngyICogKnkyOwp9Cgp2b2lkIGJ1bnN5byggIGludCAqeDEsIGludCAqeDIsIGludCAqeTEsIGludCAqeTIsIGludCAqYjEsIGludCAqYjIpCnsKICAgICpiMSA9ICp4MSAqKnkyOwogICAgKmIyID0gKngyICoqeTE7Cn0KCnZvaWQgeWFrdWJ1biggIGludCAqbjEsIGludCAqbjIpCnsKICAgIGludCB3MSA9ICpuMTsKICAgIGludCB3MiA9ICpuMjsKICAgIGludCB0OwoKICAgIGlmICh3MSA8IDApdzEgKj0gLTE7CiAgICBpZiAodzIgPCAwKXcyICo9IC0xOwogICAgd2hpbGUgKHcxICogdzIpCiAgICB7CiAgICAgICAgdzEgJT0gdzI7CiAgICAgICAgdCA9IHcxOyB3MSA9IHcyOyB3MiA9IHQ7CiAgICB9CiAgICAqbjEgLz0gdzE7CiAgICAqbjIgLz0gdzE7Cn0K