Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Lab 11 v1.0
//gcc 5.4.0 #include <stdio.h> #include <string.h> typedef struct{ int n; int d; }fraction; int add(fraction a,fraction b){ int A,B,C,s; A=a.n*b.d; B=a.n*b.d; C=a.d*b.d; s=A+B; printf("{%d+%d)/%d=%d/%d",a,b,B,s,B); } int subtract(fraction a,fraction b){ int A,B,C,s; A=a.n*b.d; B=a.n*b.d; C=a.d*b.d; s=A-B; printf("{%d+%d)/%d = %d/%d",A,B,C,s,B); } int multiply(fraction a,fraction b){ int A,B; A=a.n*b.n; B=a.d*b.d; printf("{%d/%d)*(%d/%d) = %d/%d",a.n,a.d,b.n,b.d,A,B); return(0); } int divide(fraction a,fraction b){ int A,B; A=a.n*b.d; B=a.d*b.n; printf("{%d/%d)*(%d/%d) = %d/%d",a.n,a.d,b.n,b.d,A,B); } int main(void) { int o=0; while(o<1){ int c=0; fraction a; fraction b; //int v[4]; scanf("%d",&c); switch(c){ case 1: scanf("%d",&a.n); scanf("%d",&a.d); scanf("%d",&b.n); scanf("%d",&b.d); add(a,b); continue; case 2: scanf("%d",&a.n); scanf("%d",&a.d); scanf("%d",&b.n); scanf("%d",&b.d); subtract(a,b); continue; case 3: scanf("%d",&a.n); scanf("%d",&a.d); scanf("%d",&b.n); scanf("%d",&b.d); multiply(a,b); continue; case 4: scanf("%d",&a.n); scanf("%d",&a.d); scanf("%d",&b.n); scanf("%d",&b.d); divide(a,b); continue; case 5: printf("Goodbye :)"); o++; return(0); } } }
run
|
edit
|
history
|
help
0
garbage
recurs2
A141107_Potencia
HW22
Array non repeated alphabets
SumIt
22nd HW Switchv1.0
Area and Volume coding
WrongWay reversible iterator Copyright(C) 2016 Henry Kroll III www.thenerdshow.com
Partition