kazuyamaa/multi-language-messages-01 huggingface dataset:
Task: Multiplication tables
C#: using System;

namespace multtbl
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write(" X".PadRight(4));
            for (int i = 1; i <= 12; i++)
                Console.Write(i.ToString("####").PadLeft(4));

            Console.WriteLine();
            Console.Write(" ___");

            for (int i = 1; i <= 12; i++)
                Console.Write(" ___");

            Console.WriteLine();
            for (int row = 1; row <= 12; row++)
            {
                Console.Write(row.ToString("###").PadLeft(3).PadRight(4));
                for (int col = 1; col <= 12; col++)
                {
                    if (row <= col)
                        Console.Write((row * col).ToString("###").PadLeft(4));
                    else
                        Console.Write("".PadLeft(4));
                }

                Console.WriteLine();
            }

            Console.WriteLine();
            Console.ReadLine();
        }
    }
}

Go: package main

import (
    "fmt"
)

func main() {
    fmt.Print(" x |")
    for i := 1; i <= 12; i++ {
        fmt.Printf("%4d", i)
    }
    fmt.Print("\n---+")
    for i := 1; i <= 12; i++ {
        fmt.Print("----")
    }
    for j := 1; j <= 12; j++ {
        fmt.Printf("\n%2d |", j)
        for i := 1; i <= 12; i++ {
            if i >= j {
                fmt.Printf("%4d", i*j)
            } else {
                fmt.Print("    ")
            }
        }
    }
    fmt.Println("")
}
Task: Multiplication tables
C#: using System;

namespace multtbl
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write(" X".PadRight(4));
            for (int i = 1; i <= 12; i++)
                Console.Write(i.ToString("####").PadLeft(4));

            Console.WriteLine();
            Console.Write(" ___");

            for (int i = 1; i <= 12; i++)
                Console.Write(" ___");

            Console.WriteLine();
            for (int row = 1; row <= 12; row++)
            {
                Console.Write(row.ToString("###").PadLeft(3).PadRight(4));
                for (int col = 1; col <= 12; col++)
                {
                    if (row <= col)
                        Console.Write((row * col).ToString("###").PadLeft(4));
                    else
                        Console.Write("".PadLeft(4));
                }

                Console.WriteLine();
            }

            Console.WriteLine();
            Console.ReadLine();
        }
    }
}

VB: Option Explicit

Sub Multiplication_Tables()
Dim strTemp As String, strBuff As String
Dim i&, j&, NbDigits As Byte


Const NB_END As Byte = 12

    Select Case NB_END
        Case Is < 10: NbDigits = 3
        Case 10 To 31: NbDigits = 4
        Case 31 To 100: NbDigits = 5
        Case Else: MsgBox "Number too large": Exit Sub
    End Select
    strBuff = String(NbDigits, " ")
    
    For i = 1 To NB_END
        strTemp = Right(strBuff & i, NbDigits)
        For j = 2 To NB_END
            If j < i Then
                strTemp = strTemp & strBuff
            Else
                strTemp = strTemp & Right(strBuff & j * i, NbDigits)
            End If
        Next j
        Debug.Print strTemp
    Next i
End Sub
Task: Multiplication tables
Go: package main

import (
    "fmt"
)

func main() {
    fmt.Print(" x |")
    for i := 1; i <= 12; i++ {
        fmt.Printf("%4d", i)
    }
    fmt.Print("\n---+")
    for i := 1; i <= 12; i++ {
        fmt.Print("----")
    }
    for j := 1; j <= 12; j++ {
        fmt.Printf("\n%2d |", j)
        for i := 1; i <= 12; i++ {
            if i >= j {
                fmt.Printf("%4d", i*j)
            } else {
                fmt.Print("    ")
            }
        }
    }
    fmt.Println("")
}

Java: public class MultiplicationTable {
    public static void main(String[] args) {
        for (int i = 1; i <= 12; i++)
            System.out.print("\t" + i);
        
        System.out.println();
        for (int i = 0; i < 100; i++)
            System.out.print("-");
        System.out.println();
        for (int i = 1; i <= 12; i++) {
            System.out.print(i + "|");
            for(int j = 1; j <= 12; j++) {
                System.out.print("\t");
                if (j >= i)
                    System.out.print("\t" + i * j);
            }
            System.out.println();
        }
    }
}
Task: Multiplication tables
Java: public class MultiplicationTable {
    public static void main(String[] args) {
        for (int i = 1; i <= 12; i++)
            System.out.print("\t" + i);
        
        System.out.println();
        for (int i = 0; i < 100; i++)
            System.out.print("-");
        System.out.println();
        for (int i = 1; i <= 12; i++) {
            System.out.print(i + "|");
            for(int j = 1; j <= 12; j++) {
                System.out.print("\t");
                if (j >= i)
                    System.out.print("\t" + i * j);
            }
            System.out.println();
        }
    }
}

Python: >>> size = 12
>>> width = len(str(size**2))
>>> for row in range(-1,size+1):
	if row==0:
		print("─"*width + "┼"+"─"*((width+1)*size-1))
	else:
		print("".join("%*s%1s" % ((width,) + (("x","│")      if row==-1 and col==0
					              else (row,"│") if row>0   and col==0
					              else (col,"")  if row==-1
					              else ("","")   if row>col
					              else (row*col,"")))
			       for col in range(size+1)))

		
  x│  1   2   3   4   5   6   7   8   9  10  11  12 
───┼───────────────────────────────────────────────
  1│  1   2   3   4   5   6   7   8   9  10  11  12 
  2│      4   6   8  10  12  14  16  18  20  22  24 
  3│          9  12  15  18  21  24  27  30  33  36 
  4│             16  20  24  28  32  36  40  44  48 
  5│                 25  30  35  40  45  50  55  60 
  6│                     36  42  48  54  60  66  72 
  7│                         49  56  63  70  77  84 
  8│                             64  72  80  88  96 
  9│                                 81  90  99 108 
 10│                                    100 110 120 
 11│                                        121 132 
 12│                                            144 
>>>
Task: Multiplication tables
Go: package main

import (
    "fmt"
)

func main() {
    fmt.Print(" x |")
    for i := 1; i <= 12; i++ {
        fmt.Printf("%4d", i)
    }
    fmt.Print("\n---+")
    for i := 1; i <= 12; i++ {
        fmt.Print("----")
    }
    for j := 1; j <= 12; j++ {
        fmt.Printf("\n%2d |", j)
        for i := 1; i <= 12; i++ {
            if i >= j {
                fmt.Printf("%4d", i*j)
            } else {
                fmt.Print("    ")
            }
        }
    }
    fmt.Println("")
}

Python: >>> size = 12
>>> width = len(str(size**2))
>>> for row in range(-1,size+1):
	if row==0:
		print("─"*width + "┼"+"─"*((width+1)*size-1))
	else:
		print("".join("%*s%1s" % ((width,) + (("x","│")      if row==-1 and col==0
					              else (row,"│") if row>0   and col==0
					              else (col,"")  if row==-1
					              else ("","")   if row>col
					              else (row*col,"")))
			       for col in range(size+1)))

		
  x│  1   2   3   4   5   6   7   8   9  10  11  12 
───┼───────────────────────────────────────────────
  1│  1   2   3   4   5   6   7   8   9  10  11  12 
  2│      4   6   8  10  12  14  16  18  20  22  24 
  3│          9  12  15  18  21  24  27  30  33  36 
  4│             16  20  24  28  32  36  40  44  48 
  5│                 25  30  35  40  45  50  55  60 
  6│                     36  42  48  54  60  66  72 
  7│                         49  56  63  70  77  84 
  8│                             64  72  80  88  96 
  9│                                 81  90  99 108 
 10│                                    100 110 120 
 11│                                        121 132 
 12│                                            144 
>>>
Task: Multiplication tables
C: #include <stdio.h>

int main(void)
{
	int i, j, n = 12;
 
	for (j = 1; j <= n; j++) printf("%3d%c", j, j != n ? ' ' : '\n');
	for (j = 0; j <= n; j++) printf(j != n ? "----" : "+\n");

	for (i = 1; i <= n; i++) {
		for (j = 1; j <= n; j++)
			printf(j < i ? "    " : "%3d ", i * j);
                printf("| %d\n", i);
        }
 
	return 0;
}

Go: package main

import (
    "fmt"
)

func main() {
    fmt.Print(" x |")
    for i := 1; i <= 12; i++ {
        fmt.Printf("%4d", i)
    }
    fmt.Print("\n---+")
    for i := 1; i <= 12; i++ {
        fmt.Print("----")
    }
    for j := 1; j <= 12; j++ {
        fmt.Printf("\n%2d |", j)
        for i := 1; i <= 12; i++ {
            if i >= j {
                fmt.Printf("%4d", i*j)
            } else {
                fmt.Print("    ")
            }
        }
    }
    fmt.Println("")
}
Task: Multiplication tables
C#: using System;

namespace multtbl
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write(" X".PadRight(4));
            for (int i = 1; i <= 12; i++)
                Console.Write(i.ToString("####").PadLeft(4));

            Console.WriteLine();
            Console.Write(" ___");

            for (int i = 1; i <= 12; i++)
                Console.Write(" ___");

            Console.WriteLine();
            for (int row = 1; row <= 12; row++)
            {
                Console.Write(row.ToString("###").PadLeft(3).PadRight(4));
                for (int col = 1; col <= 12; col++)
                {
                    if (row <= col)
                        Console.Write((row * col).ToString("###").PadLeft(4));
                    else
                        Console.Write("".PadLeft(4));
                }

                Console.WriteLine();
            }

            Console.WriteLine();
            Console.ReadLine();
        }
    }
}

Java: public class MultiplicationTable {
    public static void main(String[] args) {
        for (int i = 1; i <= 12; i++)
            System.out.print("\t" + i);
        
        System.out.println();
        for (int i = 0; i < 100; i++)
            System.out.print("-");
        System.out.println();
        for (int i = 1; i <= 12; i++) {
            System.out.print(i + "|");
            for(int j = 1; j <= 12; j++) {
                System.out.print("\t");
                if (j >= i)
                    System.out.print("\t" + i * j);
            }
            System.out.println();
        }
    }
}
Task: Multiplication tables
Go: package main

import (
    "fmt"
)

func main() {
    fmt.Print(" x |")
    for i := 1; i <= 12; i++ {
        fmt.Printf("%4d", i)
    }
    fmt.Print("\n---+")
    for i := 1; i <= 12; i++ {
        fmt.Print("----")
    }
    for j := 1; j <= 12; j++ {
        fmt.Printf("\n%2d |", j)
        for i := 1; i <= 12; i++ {
            if i >= j {
                fmt.Printf("%4d", i*j)
            } else {
                fmt.Print("    ")
            }
        }
    }
    fmt.Println("")
}

VB: Option Explicit

Sub Multiplication_Tables()
Dim strTemp As String, strBuff As String
Dim i&, j&, NbDigits As Byte


Const NB_END As Byte = 12

    Select Case NB_END
        Case Is < 10: NbDigits = 3
        Case 10 To 31: NbDigits = 4
        Case 31 To 100: NbDigits = 5
        Case Else: MsgBox "Number too large": Exit Sub
    End Select
    strBuff = String(NbDigits, " ")
    
    For i = 1 To NB_END
        strTemp = Right(strBuff & i, NbDigits)
        For j = 2 To NB_END
            If j < i Then
                strTemp = strTemp & strBuff
            Else
                strTemp = strTemp & Right(strBuff & j * i, NbDigits)
            End If
        Next j
        Debug.Print strTemp
    Next i
End Sub
Task: Multiplication tables
C#: using System;

namespace multtbl
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write(" X".PadRight(4));
            for (int i = 1; i <= 12; i++)
                Console.Write(i.ToString("####").PadLeft(4));

            Console.WriteLine();
            Console.Write(" ___");

            for (int i = 1; i <= 12; i++)
                Console.Write(" ___");

            Console.WriteLine();
            for (int row = 1; row <= 12; row++)
            {
                Console.Write(row.ToString("###").PadLeft(3).PadRight(4));
                for (int col = 1; col <= 12; col++)
                {
                    if (row <= col)
                        Console.Write((row * col).ToString("###").PadLeft(4));
                    else
                        Console.Write("".PadLeft(4));
                }

                Console.WriteLine();
            }

            Console.WriteLine();
            Console.ReadLine();
        }
    }
}

Python: >>> size = 12
>>> width = len(str(size**2))
>>> for row in range(-1,size+1):
	if row==0:
		print("─"*width + "┼"+"─"*((width+1)*size-1))
	else:
		print("".join("%*s%1s" % ((width,) + (("x","│")      if row==-1 and col==0
					              else (row,"│") if row>0   and col==0
					              else (col,"")  if row==-1
					              else ("","")   if row>col
					              else (row*col,"")))
			       for col in range(size+1)))

		
  x│  1   2   3   4   5   6   7   8   9  10  11  12 
───┼───────────────────────────────────────────────
  1│  1   2   3   4   5   6   7   8   9  10  11  12 
  2│      4   6   8  10  12  14  16  18  20  22  24 
  3│          9  12  15  18  21  24  27  30  33  36 
  4│             16  20  24  28  32  36  40  44  48 
  5│                 25  30  35  40  45  50  55  60 
  6│                     36  42  48  54  60  66  72 
  7│                         49  56  63  70  77  84 
  8│                             64  72  80  88  96 
  9│                                 81  90  99 108 
 10│                                    100 110 120 
 11│                                        121 132 
 12│                                            144 
>>>
Task: Multiplication tables
Java: public class MultiplicationTable {
    public static void main(String[] args) {
        for (int i = 1; i <= 12; i++)
            System.out.print("\t" + i);
        
        System.out.println();
        for (int i = 0; i < 100; i++)
            System.out.print("-");
        System.out.println();
        for (int i = 1; i <= 12; i++) {
            System.out.print(i + "|");
            for(int j = 1; j <= 12; j++) {
                System.out.print("\t");
                if (j >= i)
                    System.out.print("\t" + i * j);
            }
            System.out.println();
        }
    }
}

VB: Option Explicit

Sub Multiplication_Tables()
Dim strTemp As String, strBuff As String
Dim i&, j&, NbDigits As Byte


Const NB_END As Byte = 12

    Select Case NB_END
        Case Is < 10: NbDigits = 3
        Case 10 To 31: NbDigits = 4
        Case 31 To 100: NbDigits = 5
        Case Else: MsgBox "Number too large": Exit Sub
    End Select
    strBuff = String(NbDigits, " ")
    
    For i = 1 To NB_END
        strTemp = Right(strBuff & i, NbDigits)
        For j = 2 To NB_END
            If j < i Then
                strTemp = strTemp & strBuff
            Else
                strTemp = strTemp & Right(strBuff & j * i, NbDigits)
            End If
        Next j
        Debug.Print strTemp
    Next i
End Sub
Task: Multiplication tables
Python: >>> size = 12
>>> width = len(str(size**2))
>>> for row in range(-1,size+1):
	if row==0:
		print("─"*width + "┼"+"─"*((width+1)*size-1))
	else:
		print("".join("%*s%1s" % ((width,) + (("x","│")      if row==-1 and col==0
					              else (row,"│") if row>0   and col==0
					              else (col,"")  if row==-1
					              else ("","")   if row>col
					              else (row*col,"")))
			       for col in range(size+1)))

		
  x│  1   2   3   4   5   6   7   8   9  10  11  12 
───┼───────────────────────────────────────────────
  1│  1   2   3   4   5   6   7   8   9  10  11  12 
  2│      4   6   8  10  12  14  16  18  20  22  24 
  3│          9  12  15  18  21  24  27  30  33  36 
  4│             16  20  24  28  32  36  40  44  48 
  5│                 25  30  35  40  45  50  55  60 
  6│                     36  42  48  54  60  66  72 
  7│                         49  56  63  70  77  84 
  8│                             64  72  80  88  96 
  9│                                 81  90  99 108 
 10│                                    100 110 120 
 11│                                        121 132 
 12│                                            144 
>>>

VB: Option Explicit

Sub Multiplication_Tables()
Dim strTemp As String, strBuff As String
Dim i&, j&, NbDigits As Byte


Const NB_END As Byte = 12

    Select Case NB_END
        Case Is < 10: NbDigits = 3
        Case 10 To 31: NbDigits = 4
        Case 31 To 100: NbDigits = 5
        Case Else: MsgBox "Number too large": Exit Sub
    End Select
    strBuff = String(NbDigits, " ")
    
    For i = 1 To NB_END
        strTemp = Right(strBuff & i, NbDigits)
        For j = 2 To NB_END
            If j < i Then
                strTemp = strTemp & strBuff
            Else
                strTemp = strTemp & Right(strBuff & j * i, NbDigits)
            End If
        Next j
        Debug.Print strTemp
    Next i
End Sub
Task: Find the intersection of two lines
C: #include<stdlib.h>
#include<stdio.h>
#include<math.h>

typedef struct{
	double x,y;
}point;

double lineSlope(point a,point b){
	
	if(a.x-b.x == 0.0)
		return NAN;
	else
		return (a.y-b.y)/(a.x-b.x);
}

point extractPoint(char* str){
	int i,j,start,end,length;
	char* holder;
	point c;
	
	for(i=0;str[i]!=00;i++){
		if(str[i]=='(')
			start = i;
		if(str[i]==','||str[i]==')')
		{
			end = i;
			
			length = end - start;
			
			holder = (char*)malloc(length*sizeof(char));
			
			for(j=0;j<length-1;j++)
				holder[j] = str[start + j + 1];
			holder[j] = 00;
			
			if(str[i]==','){
				start = i;
				c.x = atof(holder);
			}
			else
				c.y = atof(holder);
		}
	}
	
	return c;
}

point intersectionPoint(point a1,point a2,point b1,point b2){
	point c;
	
	double slopeA = lineSlope(a1,a2), slopeB = lineSlope(b1,b2);
	
	if(slopeA==slopeB){
		c.x = NAN;
		c.y = NAN;
	}
	else if(isnan(slopeA) && !isnan(slopeB)){
		c.x = a1.x;
		c.y = (a1.x-b1.x)*slopeB + b1.y;
	}
	else if(isnan(slopeB) && !isnan(slopeA)){
		c.x = b1.x;
		c.y = (b1.x-a1.x)*slopeA + a1.y;
	}
	else{
		c.x = (slopeA*a1.x - slopeB*b1.x + b1.y - a1.y)/(slopeA - slopeB);
		c.y = slopeB*(c.x - b1.x) + b1.y;
	}
	
	return c;
}

int main(int argC,char* argV[])
{
	point c;
	
	if(argC < 5)
		printf("Usage : %s <four points specified as (x,y) separated by a space>",argV[0]);
	else{
		c = intersectionPoint(extractPoint(argV[1]),extractPoint(argV[2]),extractPoint(argV[3]),extractPoint(argV[4]));
		
		if(isnan(c.x))
			printf("The lines do not intersect, they are either parallel or co-incident.");
		else
			printf("Point of intersection : (%lf,%lf)",c.x,c.y);
	}
	
	return 0;
}

C#: using System;
using System.Drawing;
public class Program
{
    static PointF FindIntersection(PointF s1, PointF e1, PointF s2, PointF e2) {
        float a1 = e1.Y - s1.Y;
        float b1 = s1.X - e1.X;
        float c1 = a1 * s1.X + b1 * s1.Y;

        float a2 = e2.Y - s2.Y;
        float b2 = s2.X - e2.X;
        float c2 = a2 * s2.X + b2 * s2.Y;

        float delta = a1 * b2 - a2 * b1;
        
        return delta == 0 ? new PointF(float.NaN, float.NaN)
            : new PointF((b2 * c1 - b1 * c2) / delta, (a1 * c2 - a2 * c1) / delta);
    }

    static void Main() {
        Func<float, float, PointF> p = (x, y) => new PointF(x, y);
        Console.WriteLine(FindIntersection(p(4f, 0f), p(6f, 10f), p(0f, 3f), p(10f, 7f)));
        Console.WriteLine(FindIntersection(p(0f, 0f), p(1f, 1f), p(1f, 2f), p(4f, 5f)));
    }
}
Task: Find the intersection of two lines
C: #include<stdlib.h>
#include<stdio.h>
#include<math.h>

typedef struct{
	double x,y;
}point;

double lineSlope(point a,point b){
	
	if(a.x-b.x == 0.0)
		return NAN;
	else
		return (a.y-b.y)/(a.x-b.x);
}

point extractPoint(char* str){
	int i,j,start,end,length;
	char* holder;
	point c;
	
	for(i=0;str[i]!=00;i++){
		if(str[i]=='(')
			start = i;
		if(str[i]==','||str[i]==')')
		{
			end = i;
			
			length = end - start;
			
			holder = (char*)malloc(length*sizeof(char));
			
			for(j=0;j<length-1;j++)
				holder[j] = str[start + j + 1];
			holder[j] = 00;
			
			if(str[i]==','){
				start = i;
				c.x = atof(holder);
			}
			else
				c.y = atof(holder);
		}
	}
	
	return c;
}

point intersectionPoint(point a1,point a2,point b1,point b2){
	point c;
	
	double slopeA = lineSlope(a1,a2), slopeB = lineSlope(b1,b2);
	
	if(slopeA==slopeB){
		c.x = NAN;
		c.y = NAN;
	}
	else if(isnan(slopeA) && !isnan(slopeB)){
		c.x = a1.x;
		c.y = (a1.x-b1.x)*slopeB + b1.y;
	}
	else if(isnan(slopeB) && !isnan(slopeA)){
		c.x = b1.x;
		c.y = (b1.x-a1.x)*slopeA + a1.y;
	}
	else{
		c.x = (slopeA*a1.x - slopeB*b1.x + b1.y - a1.y)/(slopeA - slopeB);
		c.y = slopeB*(c.x - b1.x) + b1.y;
	}
	
	return c;
}

int main(int argC,char* argV[])
{
	point c;
	
	if(argC < 5)
		printf("Usage : %s <four points specified as (x,y) separated by a space>",argV[0]);
	else{
		c = intersectionPoint(extractPoint(argV[1]),extractPoint(argV[2]),extractPoint(argV[3]),extractPoint(argV[4]));
		
		if(isnan(c.x))
			printf("The lines do not intersect, they are either parallel or co-incident.");
		else
			printf("Point of intersection : (%lf,%lf)",c.x,c.y);
	}
	
	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <cassert>
using namespace std;


inline double Det(double a, double b, double c, double d)
{
	return a*d - b*c;
}



bool LineLineIntersect(double x1, double y1, 
	double x2, double y2, 
	double x3, double y3, 
	double x4, double y4, 
	double &ixOut, double &iyOut) 
{
	double detL1 = Det(x1, y1, x2, y2);
	double detL2 = Det(x3, y3, x4, y4);
	double x1mx2 = x1 - x2;
	double x3mx4 = x3 - x4;
	double y1my2 = y1 - y2;
	double y3my4 = y3 - y4;

	double denom = Det(x1mx2, y1my2, x3mx4, y3my4);
	if(denom == 0.0) 
	{
		ixOut = NAN;
		iyOut = NAN;
		return false;
	}

	double xnom = Det(detL1, x1mx2, detL2, x3mx4);
	double ynom = Det(detL1, y1my2, detL2, y3my4);
	ixOut = xnom / denom;	
	iyOut = ynom / denom;
	if(!isfinite(ixOut) || !isfinite(iyOut)) 
		return false;

	return true; 
}

int main()
{
	

	
	double x1=4.0, y1=0.0;
	double x2=6.0, y2=10.0;
	
	
	double x3=0.0, y3=3.0;
	double x4=10.0, y4=7.0;

	double ix = -1.0, iy = -1.0;
	bool result = LineLineIntersect(x1, y1, x2, y2, x3, y3, x4, y4, ix, iy);
	cout << "result " <<  result << "," << ix << "," << iy << endl;

	double eps = 1e-6;
	assert(result == true);
	assert(fabs(ix - 5.0) < eps);
	assert(fabs(iy - 5.0) < eps);
        return 0;
}