# URI Online Judge Solution 1022 TDA Rational – Solution in C, C++, Java, Python and C#

### URI Online Judge Solution 1002 Area of a Circle – Solution in C, C++, Java, Python and C#

URI Online Judge Solution 1022 TDA Rational  | Beginner

Problem Name: 1022 TDA Rational solution
Problem Number : URI – 1022 TDA Rational code
Online Judge : URI Online Judge Solution
Category: Beginner
Solution Language : C,C plus plus, java, python, c#(c sharp)

### URI Solution 1022 TDA Rational  problem simple input output:

 Input Sample Output Sample 41 / 2 + 3 / 41 / 2 – 3 / 42 / 3 * 6 / 61 / 2 / 3 / 4 10/8 = 5/4-2/8 = -1/412/18 = 2/34/6 = 2/3

### URI Solution 1022 TDA Rational  Code in C:

``#include <stdio.h>int euclides(int a, int b){    int divisor, dividendo, c;    if(a == 0)        return 1;    if(b > a)    {        dividendo = b;        divisor = a;    }    else    {        dividendo = a;        divisor = b;    }    while(dividendo % divisor != 0)    {        c = dividendo % divisor;        dividendo = divisor;        divisor = c;    }    return divisor;}int main(){    char c1, c2, c3;    int n, N1, N2, D1, D2, num, den, numS, denS, e;    scanf("%i", &n);    int i;    for (i = 0; i < n; ++i)    {        scanf("%i %c %i %c %i %c %i", &N1, &c1, &D1, &c2, &N2, &c3, &D2);        if(c2 == '+')        {            num = ((N1 * D2) + (N2 * D1));            den = (D1 * D2);        }        else if(c2 == '-')        {            num = ((N1 * D2) - (N2 * D1));            den = (D1 * D2);        }        else if(c2 == '*')        {            num = (N1 * N2);            den = (D1 * D2);        }        else        {            num = (N1 * D2);            den = (N2 * D1);        }        e = euclides(num, den);        numS = num / e;        denS = den / e;        if(numS > 0 && denS > 0)        {            printf("%i/%i = %i/%in", num, den, numS, denS);        }        else        {            if(denS < 0)            {                denS = -denS;                numS = -numS;            }            printf("%i/%i = %i/%in", num, den, numS, denS);        }    }    return 0;}``

### URI Solution 1022 TDA Rational  Code in c++/ URI 1022 solution in CPP:

``#include <cstdio>using namespace std;int euclides(int a, int b){ int divisor, dividendo, c; if(a == 0)  return 1; if(b > a){  dividendo = b;  divisor = a; }else{  dividendo = a;  divisor = b; } while(dividendo % divisor != 0) {  c = dividendo % divisor;  dividendo = divisor;  divisor = c; } return divisor;}int main(){ char c1, c2, c3; int n, N1, N2, D1, D2, num, den, numS, denS, e; scanf("%i", &n); for (int i = 0; i < n; ++i) {  scanf("%i %c %i %c %i %c %i", &N1, &c1, &D1, &c2, &N2, &c3, &D2);  if(c2 == '+'){   num = ((N1 * D2) + (N2 * D1));   den = (D1 * D2);  }else if(c2 == '-'){   num = ((N1 * D2) - (N2 * D1));   den = (D1 * D2);  }else if(c2 == '*'){   num = (N1 * N2);   den = (D1 * D2);  }else{   num = (N1 * D2);   den = (N2 * D1);  }  e = euclides(num, den);  numS = num / e;   denS = den / e;  if(numS > 0 && denS > 0){   printf("%i/%i = %i/%in", num, den, numS, denS);  }else{   if(denS < 0){    denS = -denS;    numS = -numS;   }   printf("%i/%i = %i/%in", num, den, numS, denS);  } } return 0;}``

### URI Solution 1022 TDA Rational  Code / URI 1022 solution in  C# (C Sharp):

Demonstration:

Just implement this in coding. Since having any problem just put a comment below. Thanks

Tags: URI Online Judge Solution, URI OJ Solution list, URI Problems Solution, URI solver, URI all problem solution list, URI 1022 TDA Rational  code in C, URI 1022 TDA Rational  code in C++, URI 1022 TDA Rational  solution in C, URI solution, URI 1022 TDA Rational  solution in C,URI 1022 TDA Rational  solution in C++-CPP, URI 1022 TDA Rational  solution in C# (C sharp),URI 1022 TDA Rational  solution in Java,URI 1022 TDA Rational  solution in Python,

#### By Maniruzzaman Akash

Maniruzzaman Akash is a freelance web developer with most popular Laravel PHP frameork and Vue JS