-
Notifications
You must be signed in to change notification settings - Fork 0
/
murtolukuMain.c
45 lines (43 loc) · 1.26 KB
/
murtolukuMain.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdio.h>
#include "murtoluku.h"
int main(int argc, char *argv[])
{
tulostaML( supistettuML(99,33) );
printf("\n");
tulostaML( supistettuML(17,31) );
printf("\n");
tulostaML( supistettuML(100, -10) );
printf("\n");
tulostaML( supistettuML(100, 10) );
printf("\n");
/*tulostaML( supistettuML(100,0) );
*/
/* --- */
int i = 0;
Murtoluku mlt[4] = {{4, 8}, {-5, -10}, {10, -2}, {225, 1150}};
printf("Lukujen sievennys:\n");
for(i = 0; i < 4; ++i)
{
printf("%d/%d = ", mlt[i].os, mlt[i].nim);
mlt[i] = supistettuML(mlt[i].os, mlt[i].nim);
tulostaML(mlt[i]);
printf("\n");
}
printf("Laskutoimituksia:\n");
for(i = 1; i < 4; ++i)
{
tulostaML(mlt[i-1]); printf(" + "); tulostaML(mlt[i]);
printf(" = "); tulostaML(lisaaML(mlt[i-1], mlt[i]));
printf("\n");
tulostaML(mlt[i-1]); printf(" - "); tulostaML(mlt[i]);
printf(" = "); tulostaML(vahennaML(mlt[i-1], mlt[i]));
printf("\n");
tulostaML(mlt[i-1]); printf(" * "); tulostaML(mlt[i]);
printf(" = "); tulostaML(kerroML(mlt[i-1], mlt[i]));
printf("\n");
tulostaML(mlt[i-1]); printf(" / "); tulostaML(mlt[i]);
printf(" = "); tulostaML(jaaML(mlt[i-1], mlt[i]));
printf("\n");
}
return 0;
}