From c84650b4231e23234519881d6d82347870349aad Mon Sep 17 00:00:00 2001 From: Koen Wermer <koenwermer@gmail.com> Date: Sat, 18 Feb 2017 19:32:06 +0100 Subject: [PATCH] java version of jacco's last 4 mutations added --- Equivalent mutations/2D_to_1D.java | 71 ++++++++++++++++ .../Mutants/2D_to_1D_no_1D.java | 60 ++++++++++++++ .../Mutants/2D_to_1D_no_counter.java | 70 ++++++++++++++++ .../Mutants/Vectors01Generator_no_for.java | 38 +++++++++ .../Vectors01Generator_print_string.java | 40 ++++++++++ Equivalent mutations/Vectors01Generator.java | 39 +++++++++ .../original C# code/2D_to_1D_no_1D.cs | 74 +++++++++++++++++ .../original C# code/2D_to_1D_no_counter.cs | 80 +++++++++++++++++++ .../Vectors01Generator_no_for.cs | 40 ++++++++++ .../Vectors01Generator_print_string.cs | 42 ++++++++++ 10 files changed, 554 insertions(+) create mode 100644 Equivalent mutations/2D_to_1D.java create mode 100644 Equivalent mutations/Mutants/2D_to_1D_no_1D.java create mode 100644 Equivalent mutations/Mutants/2D_to_1D_no_counter.java create mode 100644 Equivalent mutations/Mutants/Vectors01Generator_no_for.java create mode 100644 Equivalent mutations/Mutants/Vectors01Generator_print_string.java create mode 100644 Equivalent mutations/Vectors01Generator.java create mode 100644 Equivalent mutations/original C# code/2D_to_1D_no_1D.cs create mode 100644 Equivalent mutations/original C# code/2D_to_1D_no_counter.cs create mode 100644 Equivalent mutations/original C# code/Vectors01Generator_no_for.cs create mode 100644 Equivalent mutations/original C# code/Vectors01Generator_print_string.cs diff --git a/Equivalent mutations/2D_to_1D.java b/Equivalent mutations/2D_to_1D.java new file mode 100644 index 0000000..779a1dc --- /dev/null +++ b/Equivalent mutations/2D_to_1D.java @@ -0,0 +1,71 @@ +//http://www.sanfoundry.com/csharp-program-convert-2darray-1darray/ + + +class twodmatrix +{ + int m, n; + int[][] a; + int[] b; + twodmatrix(int x, int y) + { + this.m = x; + this.n = y; + this.a = new int[this.m][this.n]; + this.b = new int[this.m * this.n]; + } + public void readmatrix() + { + for (int i1 = 0; i1 < this.m; i1++) + { + for (int j1 = 0; j1 < this.n; j1++) + { + System.out.printf("a[{0},{1}]=", i1, j1); + this.a[i1][j1] = System.in.read(); + } + } + } + public void printd() + { + for (int i2 = 0; i2 < this.m; i2++) + { + for (int j2 = 0; j2 < this.n; j2++) + { + System.out.printf("{0}\t", this.a[i2][j2]); + + } + System.out.printf("\n"); + } + } + public void convert() + { + int k = 0; + for (int i3 = 0; i3 < this.m; i3++) + { + for (int j3 = 0; j3 < this.n; j3++) + { + this.b[k++] = this.a[i3][j3]; + } + } + } + public void printoned() + { + this.convert(); + + for (int i4 = 0; i4 < this.m * this.n; i4++) + { + System.out.printf("{0}\t", this.b[i4]); + } + } + + + public static void main(String[] args) + { + twodmatrix obj = new twodmatrix(2,3); + System.out.printf("Enter the Elements : "); + obj.readmatrix(); + System.out.printf("\t\t Given 2-D Array(Matrix) is : "); + obj.printd(); + System.out.printf("\t\t Converted 1-D Array is : "); + obj.printoned(); + } +} \ No newline at end of file diff --git a/Equivalent mutations/Mutants/2D_to_1D_no_1D.java b/Equivalent mutations/Mutants/2D_to_1D_no_1D.java new file mode 100644 index 0000000..ec65976 --- /dev/null +++ b/Equivalent mutations/Mutants/2D_to_1D_no_1D.java @@ -0,0 +1,60 @@ +//http://www.sanfoundry.com/csharp-program-convert-2darray-1darray/ + + +class twodmatrix +{ + int m, n; + int[][] a; + int[] b; + twodmatrix(int x, int y) + { + this.m = x; + this.n = y; + this.a = new int[this.m][this.n]; + } + public void readmatrix() + { + for (int i1 = 0; i1 < this.m; i1++) + { + for (int j1 = 0; j1 < this.n; j1++) + { + System.out.printf("a[{0},{1}]=", i1, j1); + this.a[i1][j1] = System.in.read(); + } + } + } + public void printd() + { + for (int i2 = 0; i2 < this.m; i2++) + { + for (int j2 = 0; j2 < this.n; j2++) + { + System.out.printf("{0}\t", this.a[i2][j2]); + + } + System.out.printf("\n"); + } + } + public void printoned() + { + for (int i4 = 0; i4 < this.m; i4++) + { + for (int j4 = 0; j4 < this.n; j4++) + { + Console.WriteLine("{0}\t", a[i*n+j]); + } + } + } + + + public static void main(String[] args) + { + twodmatrix obj = new twodmatrix(2,3); + System.out.printf("Enter the Elements : "); + obj.readmatrix(); + System.out.printf("\t\t Given 2-D Array(Matrix) is : "); + obj.printd(); + System.out.printf("\t\t Converted 1-D Array is : "); + obj.printoned(); + } +} \ No newline at end of file diff --git a/Equivalent mutations/Mutants/2D_to_1D_no_counter.java b/Equivalent mutations/Mutants/2D_to_1D_no_counter.java new file mode 100644 index 0000000..ee1bf4b --- /dev/null +++ b/Equivalent mutations/Mutants/2D_to_1D_no_counter.java @@ -0,0 +1,70 @@ +//http://www.sanfoundry.com/csharp-program-convert-2darray-1darray/ + + +class twodmatrix +{ + int m, n; + int[][] a; + int[] b; + twodmatrix(int x, int y) + { + this.m = x; + this.n = y; + this.a = new int[this.m][this.n]; + this.b = new int[this.m * this.n]; + } + public void readmatrix() + { + for (int i1 = 0; i1 < this.m; i1++) + { + for (int j1 = 0; j1 < this.n; j1++) + { + System.out.printf("a[{0},{1}]=", i1, j1); + this.a[i1][j1] = System.in.read(); + } + } + } + public void printd() + { + for (int i2 = 0; i2 < this.m; i2++) + { + for (int j2 = 0; j2 < this.n; j2++) + { + System.out.printf("{0}\t", this.a[i2][j2]); + + } + System.out.printf("\n"); + } + } + public void convert() + { + for (int i3 = 0; i3 < this.m; i3++) + { + for (int j3 = 0; j3 < this.n; j3++) + { + this.b[i*n+j] = this.a[i3][j3]; + } + } + } + public void printoned() + { + this.convert(); + + for (int i4 = 0; i4 < this.m * this.n; i4++) + { + System.out.printf("{0}\t", this.b[i4]); + } + } + + + public static void main(String[] args) + { + twodmatrix obj = new twodmatrix(2,3); + System.out.printf("Enter the Elements : "); + obj.readmatrix(); + System.out.printf("\t\t Given 2-D Array(Matrix) is : "); + obj.printd(); + System.out.printf("\t\t Converted 1-D Array is : "); + obj.printoned(); + } +} \ No newline at end of file diff --git a/Equivalent mutations/Mutants/Vectors01Generator_no_for.java b/Equivalent mutations/Mutants/Vectors01Generator_no_for.java new file mode 100644 index 0000000..0e9ba54 --- /dev/null +++ b/Equivalent mutations/Mutants/Vectors01Generator_no_for.java @@ -0,0 +1,38 @@ +//http://www.introprogramming.info/english-intro-csharp-book/read-online/chapter-10-recursion/#demos-source-code + +class Vectors01Generator +{ + static void Gen01(int index, int[] vector1) + { + if (index == -1) + { + Print(vector1); + } + else + { + vector1[index] = 0; + Gen01(index - 1, vector1); + vector1[index] = 1; + Gen01(index - 1, vector1); + } + } + + static void Print(int[] vector2) + { + for (int i2 = 0; i2 < vector2.length; i2++) + { + System.out.printf("{0} ", i2); + } + System.out.println(); + } + + static void main() + { + System.out.print("n = "); + int number = System.in.read(); + + int[] vector3 = new int[number]; + + Gen01(number - 1, vector3); + } +} diff --git a/Equivalent mutations/Mutants/Vectors01Generator_print_string.java b/Equivalent mutations/Mutants/Vectors01Generator_print_string.java new file mode 100644 index 0000000..99c44ec --- /dev/null +++ b/Equivalent mutations/Mutants/Vectors01Generator_print_string.java @@ -0,0 +1,40 @@ +//http://www.introprogramming.info/english-intro-csharp-book/read-online/chapter-10-recursion/#demos-source-code + +class Vectors01Generator +{ + static void Gen01(int index, int[] vector1) + { + if (index == -1) + { + Print(vector1); + } + else + { + for (int i1 = 0; i1 <= 1; i1++) + { + vector1[index] = i1; + Gen01(index - 1, vector1); + } + } + } + + static void Print(int[] vector2) + { + String str = ""; + for (int i2 = 0; i2 < vector2.length; i2++) + { + str = str + Integer.toString(i2) + " "; + } + System.out.println(str); + } + + static void main() + { + System.out.print("n = "); + int number = System.in.read(); + + int[] vector3 = new int[number]; + + Gen01(number - 1, vector3); + } +} diff --git a/Equivalent mutations/Vectors01Generator.java b/Equivalent mutations/Vectors01Generator.java new file mode 100644 index 0000000..785438c --- /dev/null +++ b/Equivalent mutations/Vectors01Generator.java @@ -0,0 +1,39 @@ +//http://www.introprogramming.info/english-intro-csharp-book/read-online/chapter-10-recursion/#demos-source-code + +class Vectors01Generator +{ + static void Gen01(int index, int[] vector1) + { + if (index == -1) + { + Print(vector1); + } + else + { + for (int i1 = 0; i1 <= 1; i1++) + { + vector1[index] = i1; + Gen01(index - 1, vector1); + } + } + } + + static void Print(int[] vector2) + { + for (int i2 = 0; i2 < vector2.length; i2++) + { + System.out.printf("{0} ", i2); + } + System.out.println(); + } + + static void main() + { + System.out.print("n = "); + int number = System.in.read(); + + int[] vector3 = new int[number]; + + Gen01(number - 1, vector3); + } +} diff --git a/Equivalent mutations/original C# code/2D_to_1D_no_1D.cs b/Equivalent mutations/original C# code/2D_to_1D_no_1D.cs new file mode 100644 index 0000000..cb1992c --- /dev/null +++ b/Equivalent mutations/original C# code/2D_to_1D_no_1D.cs @@ -0,0 +1,74 @@ +//http://www.sanfoundry.com/csharp-program-convert-2darray-1darray/ + +/* + * C# Program to Convert a 2D Array into 1D Array + */ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Program +{ + class twodmatrix + { + int m, n; + int[,] a; + twodmatrix(int x, int y) + { + m = x; + n = y; + a = new int[m, n]; + } + public void readmatrix() + { + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + Console.WriteLine("a[{0},{1}]=", i, j); + a[i, j] = Convert.ToInt32(Console.ReadLine()); + } + } + } + public void printd() + { + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + Console.Write("{0}\t", a[i, j]); + + } + Console.Write("\n"); + } + } + public void convert() + { + return; + } + public void printoned() + { + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + Console.WriteLine("{0}\t", a[i*n+j]); + } + } + } + + + public static void Main(string[] args) + { + twodmatrix obj = new twodmatrix(2,3); + Console.WriteLine("Enter the Elements : "); + obj.readmatrix(); + Console.WriteLine("\t\t Given 2-D Array(Matrix) is : "); + obj.printd(); + Console.WriteLine("\t\t Converted 1-D Array is : "); + obj.printoned(); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/Equivalent mutations/original C# code/2D_to_1D_no_counter.cs b/Equivalent mutations/original C# code/2D_to_1D_no_counter.cs new file mode 100644 index 0000000..c69ec26 --- /dev/null +++ b/Equivalent mutations/original C# code/2D_to_1D_no_counter.cs @@ -0,0 +1,80 @@ +//http://www.sanfoundry.com/csharp-program-convert-2darray-1darray/ + +/* + * C# Program to Convert a 2D Array into 1D Array + */ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Program +{ + class twodmatrix + { + int m, n; + int[,] a; + int[] b; + twodmatrix(int x, int y) + { + m = x; + n = y; + a = new int[m, n]; + b = new int[m * n]; + } + public void readmatrix() + { + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + Console.WriteLine("a[{0},{1}]=", i, j); + a[i, j] = Convert.ToInt32(Console.ReadLine()); + } + } + } + public void printd() + { + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + Console.Write("{0}\t", a[i, j]); + + } + Console.Write("\n"); + } + } + public void convert() + { + for (int i = 0; i < m; i++) + { + for (int j = 0; j < n; j++) + { + b[i*n+j] = a[i, j]; + } + } + } + public void printoned() + { + for (int i = 0; i < m * n; i++) + { + Console.WriteLine("{0}\t", b[i]); + } + } + + + public static void Main(string[] args) + { + twodmatrix obj = new twodmatrix(2,3); + Console.WriteLine("Enter the Elements : "); + obj.readmatrix(); + Console.WriteLine("\t\t Given 2-D Array(Matrix) is : "); + obj.printd(); + obj.convert(); + Console.WriteLine("\t\t Converted 1-D Array is : "); + obj.printoned(); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/Equivalent mutations/original C# code/Vectors01Generator_no_for.cs b/Equivalent mutations/original C# code/Vectors01Generator_no_for.cs new file mode 100644 index 0000000..4dc7f5c --- /dev/null +++ b/Equivalent mutations/original C# code/Vectors01Generator_no_for.cs @@ -0,0 +1,40 @@ +//http://www.introprogramming.info/english-intro-csharp-book/read-online/chapter-10-recursion/#demos-source-code + +using System; + +class Vectors01Generator +{ + static void Gen01(int index, int[] vector) + { + if (index == -1) + { + Print(vector); + } + else + { + vector[index] = 0; + Gen01(index - 1, vector); + vector[index] = 1; + Gen01(index - 1, vector); + } + } + + static void Print(int[] vector) + { + foreach (int i in vector) + { + Console.Write("{0} ", i); + } + Console.WriteLine(); + } + + static void Main() + { + Console.Write("n = "); + int number = int.Parse(Console.ReadLine()); + + int[] vector = new int[number]; + + Gen01(number - 1, vector); + } +} diff --git a/Equivalent mutations/original C# code/Vectors01Generator_print_string.cs b/Equivalent mutations/original C# code/Vectors01Generator_print_string.cs new file mode 100644 index 0000000..98761c1 --- /dev/null +++ b/Equivalent mutations/original C# code/Vectors01Generator_print_string.cs @@ -0,0 +1,42 @@ +//http://www.introprogramming.info/english-intro-csharp-book/read-online/chapter-10-recursion/#demos-source-code + +using System; + +class Vectors01Generator +{ + static void Gen01(int index, int[] vector) + { + if (index == -1) + { + Print(vector); + } + else + { + for (int i = 0; i <= 1; i++) + { + vector[index] = i; + Gen01(index - 1, vector); + } + } + } + + static void Print(int[] vector) + { + String str = ""; + foreach (int i in vector) + { + str = str + i.ToString() + " "; + } + Console.WriteLine(str); + } + + static void Main() + { + Console.Write("n = "); + int number = int.Parse(Console.ReadLine()); + + int[] vector = new int[number]; + + Gen01(number - 1, vector); + } +} -- GitLab