WeixiangYan/CodeTransOcean huggingface dataset:
Task: Temperature conversion


C++: #include <iostream>
#include <iomanip>


using namespace std;


class converter
{
public:
    converter() : KTC( 273.15f ), KTDel( 3.0f / 2.0f ), KTF( 9.0f / 5.0f ), KTNew( 33.0f / 100.0f ),
          KTRank( 9.0f / 5.0f ), KTRe( 4.0f / 5.0f ), KTRom( 21.0f / 40.0f ) {}

    void convert( float kelvin )
    {
    float cel = kelvin - KTC,
          del = ( 373.15f - kelvin ) * KTDel,
          fah = kelvin * KTF - 459.67f,
          net = cel * KTNew,
          rnk = kelvin * KTRank,
          rea = cel * KTRe, 
          rom = cel * KTRom + 7.5f;

    cout << endl << left
         << "TEMPERATURES:" << endl 
         << "===============" << endl << setw( 13 )
         << "CELSIUS:" << cel << endl << setw( 13 )
         << "DELISLE:" << del << endl << setw( 13 )
         << "FAHRENHEIT:" << fah << endl << setw( 13 )
         << "KELVIN:" << kelvin << endl  << setw( 13 )
         << "NEWTON:" << net << endl << setw( 13 )
         << "RANKINE:" << rnk << endl << setw( 13 )
         << "REAUMUR:" << rea << endl << setw( 13 )
         << "ROMER:" << rom << endl << endl << endl;
    }
private:
    const float KTRank, KTC, KTF, KTRe, KTDel, KTNew, KTRom;
};

int main( int argc, char* argv[] )
{
    converter con;
    float k;
    while( true )
    {
    cout << "Enter the temperature in Kelvin to convert: ";
    cin >> k;
    con.convert( k );
    system( "pause" );
    system( "cls" );
    }
    return 0;
}




Go: package main

import (
    "fmt"
    "os"
    "strconv"
)

func main() {
    if len(os.Args) != 2 {
        fmt.Println("Usage: k <Kelvin>")
        return
    }
    k, err := strconv.ParseFloat(os.Args[1], 64)
    if err != nil {
        fmt.Println(err)
        return
    }
    if k < 0 {
        fmt.Println("Kelvin must be >= 0.")
        return
    }
    fmt.Printf("K  %.2f\n", k)
    fmt.Printf("C  %.2f\n", k-273.15)
    fmt.Printf("F  %.2f\n", k*9/5-459.67)
    fmt.Printf("R  %.2f\n", k*9/5)
}
Task: Temperature conversion

C: #include <stdio.h>
#include <stdlib.h>

double kelvinToCelsius(double k){
    return k - 273.15;
}

double kelvinToFahrenheit(double k){
    return k * 1.8 - 459.67;
}

double kelvinToRankine(double k){
    return k * 1.8;
}
void convertKelvin(double kelvin) {
    printf("K %.2f\n", kelvin);
    printf("C %.2f\n", kelvinToCelsius(kelvin));
    printf("F %.2f\n", kelvinToFahrenheit(kelvin));
    printf("R %.2f", kelvinToRankine(kelvin));
}

int main(int argc, const char * argv[])
{
    if (argc > 1) {
        double kelvin = atof(argv[1]);
        convertKelvin(kelvin);
    }
    return 0;
}


C++: #include <iostream>
#include <iomanip>


using namespace std;


class converter
{
public:
    converter() : KTC( 273.15f ), KTDel( 3.0f / 2.0f ), KTF( 9.0f / 5.0f ), KTNew( 33.0f / 100.0f ),
          KTRank( 9.0f / 5.0f ), KTRe( 4.0f / 5.0f ), KTRom( 21.0f / 40.0f ) {}

    void convert( float kelvin )
    {
    float cel = kelvin - KTC,
          del = ( 373.15f - kelvin ) * KTDel,
          fah = kelvin * KTF - 459.67f,
          net = cel * KTNew,
          rnk = kelvin * KTRank,
          rea = cel * KTRe, 
          rom = cel * KTRom + 7.5f;

    cout << endl << left
         << "TEMPERATURES:" << endl 
         << "===============" << endl << setw( 13 )
         << "CELSIUS:" << cel << endl << setw( 13 )
         << "DELISLE:" << del << endl << setw( 13 )
         << "FAHRENHEIT:" << fah << endl << setw( 13 )
         << "KELVIN:" << kelvin << endl  << setw( 13 )
         << "NEWTON:" << net << endl << setw( 13 )
         << "RANKINE:" << rnk << endl << setw( 13 )
         << "REAUMUR:" << rea << endl << setw( 13 )
         << "ROMER:" << rom << endl << endl << endl;
    }
private:
    const float KTRank, KTC, KTF, KTRe, KTDel, KTNew, KTRom;
};

int main( int argc, char* argv[] )
{
    converter con;
    float k;
    while( true )
    {
    cout << "Enter the temperature in Kelvin to convert: ";
    cin >> k;
    con.convert( k );
    system( "pause" );
    system( "cls" );
    }
    return 0;
}
Task: Temperature conversion


C++: #include <iostream>
#include <iomanip>


using namespace std;


class converter
{
public:
    converter() : KTC( 273.15f ), KTDel( 3.0f / 2.0f ), KTF( 9.0f / 5.0f ), KTNew( 33.0f / 100.0f ),
          KTRank( 9.0f / 5.0f ), KTRe( 4.0f / 5.0f ), KTRom( 21.0f / 40.0f ) {}

    void convert( float kelvin )
    {
    float cel = kelvin - KTC,
          del = ( 373.15f - kelvin ) * KTDel,
          fah = kelvin * KTF - 459.67f,
          net = cel * KTNew,
          rnk = kelvin * KTRank,
          rea = cel * KTRe, 
          rom = cel * KTRom + 7.5f;

    cout << endl << left
         << "TEMPERATURES:" << endl 
         << "===============" << endl << setw( 13 )
         << "CELSIUS:" << cel << endl << setw( 13 )
         << "DELISLE:" << del << endl << setw( 13 )
         << "FAHRENHEIT:" << fah << endl << setw( 13 )
         << "KELVIN:" << kelvin << endl  << setw( 13 )
         << "NEWTON:" << net << endl << setw( 13 )
         << "RANKINE:" << rnk << endl << setw( 13 )
         << "REAUMUR:" << rea << endl << setw( 13 )
         << "ROMER:" << rom << endl << endl << endl;
    }
private:
    const float KTRank, KTC, KTF, KTRe, KTDel, KTNew, KTRom;
};

int main( int argc, char* argv[] )
{
    converter con;
    float k;
    while( true )
    {
    cout << "Enter the temperature in Kelvin to convert: ";
    cin >> k;
    con.convert( k );
    system( "pause" );
    system( "cls" );
    }
    return 0;
}



C#: using System;

namespace TemperatureConversion
{
    class Program
    {
        static Func<double, double> ConvertKelvinToFahrenheit = x => (x * 1.8) - 459.67;
        static Func<double, double> ConvertKelvinToRankine = x => x * 1.8;
        static Func<double, double> ConvertKelvinToCelsius = x => x = 273.13;

        static void Main(string[] args)
        {
            Console.Write("Enter a Kelvin Temperature: ");
            string inputVal = Console.ReadLine();
            double kelvinTemp = 0f;

            if (double.TryParse(inputVal, out kelvinTemp))
            {
                Console.WriteLine(string.Format("Kelvin: {0}", kelvinTemp));
                Console.WriteLine(string.Format("Fahrenheit: {0}", ConvertKelvinToFahrenheit(kelvinTemp)));
                Console.WriteLine(string.Format("Rankine: {0}", ConvertKelvinToRankine(kelvinTemp)));
                Console.WriteLine(string.Format("Celsius: {0}", ConvertKelvinToCelsius(kelvinTemp)));
                Console.ReadKey();
            }
            else
            {
                Console.WriteLine("Invalid input value: " + inputVal);
            }
        }
    }
}
Task: Temperature conversion



C#: using System;

namespace TemperatureConversion
{
    class Program
    {
        static Func<double, double> ConvertKelvinToFahrenheit = x => (x * 1.8) - 459.67;
        static Func<double, double> ConvertKelvinToRankine = x => x * 1.8;
        static Func<double, double> ConvertKelvinToCelsius = x => x = 273.13;

        static void Main(string[] args)
        {
            Console.Write("Enter a Kelvin Temperature: ");
            string inputVal = Console.ReadLine();
            double kelvinTemp = 0f;

            if (double.TryParse(inputVal, out kelvinTemp))
            {
                Console.WriteLine(string.Format("Kelvin: {0}", kelvinTemp));
                Console.WriteLine(string.Format("Fahrenheit: {0}", ConvertKelvinToFahrenheit(kelvinTemp)));
                Console.WriteLine(string.Format("Rankine: {0}", ConvertKelvinToRankine(kelvinTemp)));
                Console.WriteLine(string.Format("Celsius: {0}", ConvertKelvinToCelsius(kelvinTemp)));
                Console.ReadKey();
            }
            else
            {
                Console.WriteLine("Invalid input value: " + inputVal);
            }
        }
    }
}


Go: package main

import (
    "fmt"
    "os"
    "strconv"
)

func main() {
    if len(os.Args) != 2 {
        fmt.Println("Usage: k <Kelvin>")
        return
    }
    k, err := strconv.ParseFloat(os.Args[1], 64)
    if err != nil {
        fmt.Println(err)
        return
    }
    if k < 0 {
        fmt.Println("Kelvin must be >= 0.")
        return
    }
    fmt.Printf("K  %.2f\n", k)
    fmt.Printf("C  %.2f\n", k-273.15)
    fmt.Printf("F  %.2f\n", k*9/5-459.67)
    fmt.Printf("R  %.2f\n", k*9/5)
}
Task: Temperature conversion

C: #include <stdio.h>
#include <stdlib.h>

double kelvinToCelsius(double k){
    return k - 273.15;
}

double kelvinToFahrenheit(double k){
    return k * 1.8 - 459.67;
}

double kelvinToRankine(double k){
    return k * 1.8;
}
void convertKelvin(double kelvin) {
    printf("K %.2f\n", kelvin);
    printf("C %.2f\n", kelvinToCelsius(kelvin));
    printf("F %.2f\n", kelvinToFahrenheit(kelvin));
    printf("R %.2f", kelvinToRankine(kelvin));
}

int main(int argc, const char * argv[])
{
    if (argc > 1) {
        double kelvin = atof(argv[1]);
        convertKelvin(kelvin);
    }
    return 0;
}






PHP: while (true) {
    echo "\nEnter a value in kelvin (q to quit): ";
    if ($kelvin = trim(fgets(STDIN))) {
        if ($kelvin == 'q') {
            echo 'quitting';
            break;
        }
        if (is_numeric($kelvin)) {
            $kelvin = floatVal($kelvin);
            if ($kelvin >= 0) {
                printf(" K  %2.2f\n", $kelvin);
                printf(" C  %2.2f\n", $kelvin - 273.15);
                printf(" F  %2.2f\n", $kelvin * 1.8 - 459.67);
                printf(" R  %2.2f\n", $kelvin * 1.8);
            } else printf(" %2.2f K is below absolute zero\n", $kelvin);
        }
    }
}
Task: Temperature conversion



C#: using System;

namespace TemperatureConversion
{
    class Program
    {
        static Func<double, double> ConvertKelvinToFahrenheit = x => (x * 1.8) - 459.67;
        static Func<double, double> ConvertKelvinToRankine = x => x * 1.8;
        static Func<double, double> ConvertKelvinToCelsius = x => x = 273.13;

        static void Main(string[] args)
        {
            Console.Write("Enter a Kelvin Temperature: ");
            string inputVal = Console.ReadLine();
            double kelvinTemp = 0f;

            if (double.TryParse(inputVal, out kelvinTemp))
            {
                Console.WriteLine(string.Format("Kelvin: {0}", kelvinTemp));
                Console.WriteLine(string.Format("Fahrenheit: {0}", ConvertKelvinToFahrenheit(kelvinTemp)));
                Console.WriteLine(string.Format("Rankine: {0}", ConvertKelvinToRankine(kelvinTemp)));
                Console.WriteLine(string.Format("Celsius: {0}", ConvertKelvinToCelsius(kelvinTemp)));
                Console.ReadKey();
            }
            else
            {
                Console.WriteLine("Invalid input value: " + inputVal);
            }
        }
    }
}




PHP: while (true) {
    echo "\nEnter a value in kelvin (q to quit): ";
    if ($kelvin = trim(fgets(STDIN))) {
        if ($kelvin == 'q') {
            echo 'quitting';
            break;
        }
        if (is_numeric($kelvin)) {
            $kelvin = floatVal($kelvin);
            if ($kelvin >= 0) {
                printf(" K  %2.2f\n", $kelvin);
                printf(" C  %2.2f\n", $kelvin - 273.15);
                printf(" F  %2.2f\n", $kelvin * 1.8 - 459.67);
                printf(" R  %2.2f\n", $kelvin * 1.8);
            } else printf(" %2.2f K is below absolute zero\n", $kelvin);
        }
    }
}
Task: Temperature conversion


C++: #include <iostream>
#include <iomanip>


using namespace std;


class converter
{
public:
    converter() : KTC( 273.15f ), KTDel( 3.0f / 2.0f ), KTF( 9.0f / 5.0f ), KTNew( 33.0f / 100.0f ),
          KTRank( 9.0f / 5.0f ), KTRe( 4.0f / 5.0f ), KTRom( 21.0f / 40.0f ) {}

    void convert( float kelvin )
    {
    float cel = kelvin - KTC,
          del = ( 373.15f - kelvin ) * KTDel,
          fah = kelvin * KTF - 459.67f,
          net = cel * KTNew,
          rnk = kelvin * KTRank,
          rea = cel * KTRe, 
          rom = cel * KTRom + 7.5f;

    cout << endl << left
         << "TEMPERATURES:" << endl 
         << "===============" << endl << setw( 13 )
         << "CELSIUS:" << cel << endl << setw( 13 )
         << "DELISLE:" << del << endl << setw( 13 )
         << "FAHRENHEIT:" << fah << endl << setw( 13 )
         << "KELVIN:" << kelvin << endl  << setw( 13 )
         << "NEWTON:" << net << endl << setw( 13 )
         << "RANKINE:" << rnk << endl << setw( 13 )
         << "REAUMUR:" << rea << endl << setw( 13 )
         << "ROMER:" << rom << endl << endl << endl;
    }
private:
    const float KTRank, KTC, KTF, KTRe, KTDel, KTNew, KTRom;
};

int main( int argc, char* argv[] )
{
    converter con;
    float k;
    while( true )
    {
    cout << "Enter the temperature in Kelvin to convert: ";
    cin >> k;
    con.convert( k );
    system( "pause" );
    system( "cls" );
    }
    return 0;
}






PHP: while (true) {
    echo "\nEnter a value in kelvin (q to quit): ";
    if ($kelvin = trim(fgets(STDIN))) {
        if ($kelvin == 'q') {
            echo 'quitting';
            break;
        }
        if (is_numeric($kelvin)) {
            $kelvin = floatVal($kelvin);
            if ($kelvin >= 0) {
                printf(" K  %2.2f\n", $kelvin);
                printf(" C  %2.2f\n", $kelvin - 273.15);
                printf(" F  %2.2f\n", $kelvin * 1.8 - 459.67);
                printf(" R  %2.2f\n", $kelvin * 1.8);
            } else printf(" %2.2f K is below absolute zero\n", $kelvin);
        }
    }
}
Task: Temperature conversion




Go: package main

import (
    "fmt"
    "os"
    "strconv"
)

func main() {
    if len(os.Args) != 2 {
        fmt.Println("Usage: k <Kelvin>")
        return
    }
    k, err := strconv.ParseFloat(os.Args[1], 64)
    if err != nil {
        fmt.Println(err)
        return
    }
    if k < 0 {
        fmt.Println("Kelvin must be >= 0.")
        return
    }
    fmt.Printf("K  %.2f\n", k)
    fmt.Printf("C  %.2f\n", k-273.15)
    fmt.Printf("F  %.2f\n", k*9/5-459.67)
    fmt.Printf("R  %.2f\n", k*9/5)
}



PHP: while (true) {
    echo "\nEnter a value in kelvin (q to quit): ";
    if ($kelvin = trim(fgets(STDIN))) {
        if ($kelvin == 'q') {
            echo 'quitting';
            break;
        }
        if (is_numeric($kelvin)) {
            $kelvin = floatVal($kelvin);
            if ($kelvin >= 0) {
                printf(" K  %2.2f\n", $kelvin);
                printf(" C  %2.2f\n", $kelvin - 273.15);
                printf(" F  %2.2f\n", $kelvin * 1.8 - 459.67);
                printf(" R  %2.2f\n", $kelvin * 1.8);
            } else printf(" %2.2f K is below absolute zero\n", $kelvin);
        }
    }
}
Task: Temperature conversion





Java: public class TemperatureConversion {
    public static void main(String args[]) {
        if (args.length == 1) {
            try {
                double kelvin = Double.parseDouble(args[0]);
                if (kelvin >= 0) {
                    System.out.printf("K  %2.2f\n", kelvin);
                    System.out.printf("C  %2.2f\n", kelvinToCelsius(kelvin));
                    System.out.printf("F  %2.2f\n", kelvinToFahrenheit(kelvin));
                    System.out.printf("R  %2.2f\n", kelvinToRankine(kelvin));
                } else {
                    System.out.printf("%2.2f K is below absolute zero", kelvin);
                }
            } catch (NumberFormatException e) {
                System.out.println(e);
            }
        }
    }

    public static double kelvinToCelsius(double k) {
        return k - 273.15;
    }

    public static double kelvinToFahrenheit(double k) {
        return k * 1.8 - 459.67;
    }

    public static double kelvinToRankine(double k) {
        return k * 1.8;
    }
}


PHP: while (true) {
    echo "\nEnter a value in kelvin (q to quit): ";
    if ($kelvin = trim(fgets(STDIN))) {
        if ($kelvin == 'q') {
            echo 'quitting';
            break;
        }
        if (is_numeric($kelvin)) {
            $kelvin = floatVal($kelvin);
            if ($kelvin >= 0) {
                printf(" K  %2.2f\n", $kelvin);
                printf(" C  %2.2f\n", $kelvin - 273.15);
                printf(" F  %2.2f\n", $kelvin * 1.8 - 459.67);
                printf(" R  %2.2f\n", $kelvin * 1.8);
            } else printf(" %2.2f K is below absolute zero\n", $kelvin);
        }
    }
}
Task: Temperature conversion






PHP: while (true) {
    echo "\nEnter a value in kelvin (q to quit): ";
    if ($kelvin = trim(fgets(STDIN))) {
        if ($kelvin == 'q') {
            echo 'quitting';
            break;
        }
        if (is_numeric($kelvin)) {
            $kelvin = floatVal($kelvin);
            if ($kelvin >= 0) {
                printf(" K  %2.2f\n", $kelvin);
                printf(" C  %2.2f\n", $kelvin - 273.15);
                printf(" F  %2.2f\n", $kelvin * 1.8 - 459.67);
                printf(" R  %2.2f\n", $kelvin * 1.8);
            } else printf(" %2.2f K is below absolute zero\n", $kelvin);
        }
    }
}


Python: >>> while True:
    k = float(input('K ? '))
    print("%g Kelvin = %g Celsius = %g Fahrenheit = %g Rankine degrees."
          % (k, k - 273.15, k * 1.8 - 459.67, k * 1.8))

    
K ? 21.0
21 Kelvin = -252.15 Celsius = -421.87 Fahrenheit = 37.8 Rankine degrees.
K ? 222.2
222.2 Kelvin = -50.95 Celsius = -59.71 Fahrenheit = 399.96 Rankine degrees.
K ?
Task: Temperature conversion






PHP: while (true) {
    echo "\nEnter a value in kelvin (q to quit): ";
    if ($kelvin = trim(fgets(STDIN))) {
        if ($kelvin == 'q') {
            echo 'quitting';
            break;
        }
        if (is_numeric($kelvin)) {
            $kelvin = floatVal($kelvin);
            if ($kelvin >= 0) {
                printf(" K  %2.2f\n", $kelvin);
                printf(" C  %2.2f\n", $kelvin - 273.15);
                printf(" F  %2.2f\n", $kelvin * 1.8 - 459.67);
                printf(" R  %2.2f\n", $kelvin * 1.8);
            } else printf(" %2.2f K is below absolute zero\n", $kelvin);
        }
    }
}



VB: Option Explicit

Sub Main_Conv_Temp()
Dim K As Single, Result As Single
    K = 21
    Debug.Print "Input in Kelvin      : " & Format(K, "0.00")
    Debug.Print "Output in Celsius    : " & IIf(ConvTemp(Result, K, "C"), Format(Result, "0.00"), False)
    Debug.Print "Output in Fahrenheit : " & IIf(ConvTemp(Result, K, "F"), Format(Result, "0.00"), False)
    Debug.Print "Output in Rankine    : " & IIf(ConvTemp(Result, K, "R"), Format(Result, "0.00"), False)
    Debug.Print "Output error         : " & IIf(ConvTemp(Result, K, "T"), Format(Result, "0.00"), False)
End Sub

Function ConvTemp(sngReturn As Single, Kelv As Single, InWhat As String) As Boolean
Dim ratio As Single
    
    ConvTemp = True
    ratio = 9 / 5
    Select Case UCase(InWhat)
        Case "C": sngReturn = Kelv - 273.15
        Case "F": sngReturn = (Kelv * ratio) - 459.67
        Case "R": sngReturn = Kelv * ratio
        Case Else: ConvTemp = False
    End Select
End Function
Task: Parametric polymorphism

C: #include <stdio.h>
#include <stdlib.h>

#define decl_tree_type(T)                                                       \
        typedef struct node_##T##_t node_##T##_t, *node_##T;                    \
        struct node_##T##_t { node_##T left, right; T value; };                 \
                                                                                \
        node_##T node_##T##_new(T v) {                                          \
                node_##T node = malloc(sizeof(node_##T##_t));                   \
                node->value = v;                                                \
                node->left = node->right = 0;                                   \
                return node;                                                    \
        }                                                                       \
        node_##T node_##T##_insert(node_##T root, T v) {                        \
                node_##T n = node_##T##_new(v);                                 \
                while (root) {                                                  \
                        if (root->value < n->value)                             \
                                if (!root->left) return root->left = n;         \
                                else root = root->left;                         \
                        else                                                    \
                                if (!root->right) return root->right = n;       \
                                else root = root->right;                        \
                }                                                               \
                return 0;                                                       \
        }

#define tree_node(T) node_##T
#define node_insert(T, r, x) node_##T##_insert(r, x)
#define node_new(T, x) node_##T##_new(x)

decl_tree_type(double);
decl_tree_type(int);

int main()
{
        int i;
        tree_node(double) root_d = node_new(double, (double)rand() / RAND_MAX);

        for (i = 0; i < 10000; i++)
                node_insert(double, root_d, (double)rand() / RAND_MAX);

        tree_node(int) root_i = node_new(int, rand());
        for (i = 0; i < 10000; i++)
                node_insert(int, root_i, rand());

        return 0;
}



C#: using System;

class BinaryTree<T>
{
    public T value;
    public BinaryTree<T> left;
    public BinaryTree<T> right;

    public BinaryTree(T value)
    {
        this.value = value;
    }

    public BinaryTree<U> Map<U>(Func<T, U> f)
    {
        BinaryTree<U> tree = new BinaryTree<U>(f(this.value));
        if (this.left != null)
        {
            tree.left = this.left.Map(f);
        }
        if (this.right != null)
        {
            tree.right = this.right.Map(f);
        }
        return tree;
    }
}
Task: Parametric polymorphism

C: #include <stdio.h>
#include <stdlib.h>

#define decl_tree_type(T)                                                       \
        typedef struct node_##T##_t node_##T##_t, *node_##T;                    \
        struct node_##T##_t { node_##T left, right; T value; };                 \
                                                                                \
        node_##T node_##T##_new(T v) {                                          \
                node_##T node = malloc(sizeof(node_##T##_t));                   \
                node->value = v;                                                \
                node->left = node->right = 0;                                   \
                return node;                                                    \
        }                                                                       \
        node_##T node_##T##_insert(node_##T root, T v) {                        \
                node_##T n = node_##T##_new(v);                                 \
                while (root) {                                                  \
                        if (root->value < n->value)                             \
                                if (!root->left) return root->left = n;         \
                                else root = root->left;                         \
                        else                                                    \
                                if (!root->right) return root->right = n;       \
                                else root = root->right;                        \
                }                                                               \
                return 0;                                                       \
        }

#define tree_node(T) node_##T
#define node_insert(T, r, x) node_##T##_insert(r, x)
#define node_new(T, x) node_##T##_new(x)

decl_tree_type(double);
decl_tree_type(int);

int main()
{
        int i;
        tree_node(double) root_d = node_new(double, (double)rand() / RAND_MAX);

        for (i = 0; i < 10000; i++)
                node_insert(double, root_d, (double)rand() / RAND_MAX);

        tree_node(int) root_i = node_new(int, rand());
        for (i = 0; i < 10000; i++)
                node_insert(int, root_i, rand());

        return 0;
}


C++: template<class T> 
class tree
{
  T value;
  tree *left;
  tree *right;
public:
  void replace_all (T new_value);
};