Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Lab 11 v.05
//gcc 5.4.0 #include <stdio.h> int add(struct fraction F){ int a,B,b,s; a=F[0].n*F[1].d; b=F[1].n*F[0].d; B=F[0].d*F[1].d; s=a+b; printf("{%d+%d)/%d=%d/%d",a,b,B,s,B); return(0); } int subtract(struct fraction F){ int a,B,b,s; a=F[0].n*F[1].d; b=F[1].n*F[0].d; B=F[0].d*F[1].d; s=a-b; printf("{%d+%d)/%d = %d/%d",a,b,B,s,B); return(0); } int multiply(struct fraction F){ int a,b; a=F[0].n*F[1].n; b=F[0].d*F[1].d; printf("{%d/%d)*(%d/%d) = %d/%d",F[0].n,F[0].d,F[1].n,F[1].d,a,b); return(0); } int divide(struct fraction F){ int a,b; a=F[0].n*F[1].d; b=F[0].d*F[1].n; printf("{%d/%d)*(%d/%d) = %d/%d",F[0].n,F[0].d,F[1].n,F[1].d,a,b); return(0); } int main(void) { int o=0; while(o<1){ int c=0; typedef struct{ int n; int d; }fraction; fraction F[2]; //int v[4]; scanf("%d",&c); switch(c){ case 1: scanf("%d",&F[0].n); scanf("%d",&F[0].d); scanf("%d",&F[1].n); scanf("%d",&F[1].d); add(F); continue; case 2: scanf("%d",&F[0].n); scanf("%d",&F[0].d); scanf("%d",&F[1].n); scanf("%d",&F[1].d); subtract(F); continue; case 3: scanf("%d",&F[0].n); scanf("%d",&F[0].d); scanf("%d",&F[1].n); scanf("%d",&F[1].d); multiply(F); continue; case 4: scanf("%d",&F[0].n); scanf("%d",&F[0].d); scanf("%d",&F[1].n); scanf("%d",&F[1].d); divide(F); continue; case 5: o++; return(0); } } }
run
|
edit
|
history
|
help
0
FunPointUnion
Incometax problem v0.1
table of 123
B_141202_CADENA_NUMERO
Generic Singly Linked List
Multiples of 10 sum
a3
dining phylosopher
gkckibvsj
Taco Code