Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void mult(int *x1, int *y1, int *x2, int *y2){
- long long top = (*x1) * (*x2);
- long long bottom = (*y2) * (*y1);
- long long frac;
- if(bottom != 0||top != 0){
- frac = commonDiv(top,bottom);
- }else{
- frac = 1;
- }
- string sign = "";
- if(top * bottom < 0){
- sign = "-";
- }else{
- sign = "";
- }
- printf("%s%lld / %lldn",sign.c_str(),abs(top/frac),abs(bottom/frac) );
- }
- int main()
- {
- int numOp;
- scanf("%d", &numOp);
- getPrime(1,sqrt(100000));
- while(numOp != 0){
- int x1,x2,y1,y2;
- char op[2];
- scanf("%d %d %s %d %d", &x1, &y1, op, &x2, &y2);
- if( op[0] == '+'){
- add(&x1, &y1, &x2,&y2);
- }
- else if(op[0] == '-'){
- sub(&x1,&y1,&x2,&y2);
- }
- else if(op[0] == '/'){
- divi(&x1,&y1,&x2,&y2);
- }
- else{
- mult(&x1,&y1,&x2,&y2);
- }
- numOp--;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement