From 49ccdef26ed232b5748298231ad3f2214158e093 Mon Sep 17 00:00:00 2001 From: Doni Pracner Date: Sun, 30 Aug 2015 16:15:42 +0200 Subject: [PATCH] mj samples reformated to be consistent --- samples/RekFac.mj | 6 ++++-- samples/RekFib.mj | 6 ++++-- samples/div0.mj | 3 ++- samples/div2.mj | 3 ++- samples/eratos.mj | 17 +++++++++++++---- samples/pos-neg.mj | 6 ++++-- 6 files changed, 29 insertions(+), 12 deletions(-) diff --git a/samples/RekFac.mj b/samples/RekFac.mj index 40817fd..674cc14 100644 --- a/samples/RekFac.mj +++ b/samples/RekFac.mj @@ -2,8 +2,10 @@ program RekFac{ int factorial(int f) { - if (f<0) return 0; - if (f<=1) return 1; + if (f<0) + return 0; + if (f<=1) + return 1; return factorial(f-1) * f ; } diff --git a/samples/RekFib.mj b/samples/RekFib.mj index f4e3f09..d3a59a5 100644 --- a/samples/RekFib.mj +++ b/samples/RekFib.mj @@ -2,8 +2,10 @@ program RekFib{ int fib(int f) { - if (f==0) return 0; - if (f==1) return 1; + if (f==0) + return 0; + if (f==1) + return 1; return fib(f-2)+fib(f-1) ; } diff --git a/samples/div0.mj b/samples/div0.mj index d8fb689..bd92135 100644 --- a/samples/div0.mj +++ b/samples/div0.mj @@ -3,7 +3,8 @@ program test void main() int i, j; { - i = 100; j = 0; + i = 100; + j = 0; print(i/j); } diff --git a/samples/div2.mj b/samples/div2.mj index d498e3d..455b4af 100644 --- a/samples/div2.mj +++ b/samples/div2.mj @@ -3,7 +3,8 @@ program test void main() int i, j; { - i = 100; j = 2; + i = 100; + j = 2; print(i/j); } diff --git a/samples/eratos.mj b/samples/eratos.mj index 620bd2d..92d28f8 100644 --- a/samples/eratos.mj +++ b/samples/eratos.mj @@ -7,7 +7,11 @@ program Eratos { void put(int x) { - if (npp == 10) {print(chr(13)); print(chr(10)); npp = 0;} + if (npp == 10) { + print(chr(13)); + print(chr(10)); + npp = 0; + } print(x, 5); npp++; } @@ -17,7 +21,9 @@ program Eratos { put(x); i = x; - while (i <= max) {sieve[i] = 'o'; i = i + x;} + while (i <= max) { + sieve[i] = 'o'; i = i + x; + } } void main() @@ -27,11 +33,14 @@ program Eratos npp = 0; sieve = new char[max+1]; i = 0; - while (i <= max) {sieve[i] = 'x'; i++;} + while (i <= max) { + sieve[i] = 'x'; i++; + } i = 2; while (i <= max) { found(i); - while(i <= max && sieve[i] == 'o') i++; + while(i <= max && sieve[i] == 'o') + i++; } } diff --git a/samples/pos-neg.mj b/samples/pos-neg.mj index 5bf3771..79fd454 100644 --- a/samples/pos-neg.mj +++ b/samples/pos-neg.mj @@ -10,10 +10,12 @@ program P int x, i; { //---------- Initialize val val = new Table; - val.pos = new int[size]; val.neg = new int[size]; + val.pos = new int[size]; + val.neg = new int[size]; i = 0; while (i < size) { - val.pos[i] = 0; val.neg[i] = 0; + val.pos[i] = 0; + val.neg[i] = 0; i++; } //---------- Read values -- 2.25.1