kazuyamaa/multi-language-messages-01 huggingface dataset:
Task: Sleep
Go: package main

import "time"
import "fmt"

func main() {
    fmt.Print("Enter number of seconds to sleep: ")
    var sec float64
    fmt.Scanf("%f", &sec)
    fmt.Print("Sleeping…")
    time.Sleep(time.Duration(sec * float64(time.Second)))
    fmt.Println("\nAwake!")
}

VB: input "Enter the number of seconds to sleep: ";s
sleep s
print "I
input "Press enter to quit";a$
Task: Sleep
Python: import time

seconds = float(raw_input())
print "Sleeping..."
time.sleep(seconds) 
print "Awake!"

VB: input "Enter the number of seconds to sleep: ";s
sleep s
print "I
input "Press enter to quit";a$
Task: Sleep
C: #include <stdio.h>
#include <unistd.h>

int main()
{
  unsigned int seconds;
  scanf("%u", &seconds);
  printf("Sleeping...\n");
  sleep(seconds);
  printf("Awake!\n");
  return 0;
}

Python: import time

seconds = float(raw_input())
print "Sleeping..."
time.sleep(seconds) 
print "Awake!"
Task: Sleep
C#: using System;
using System.Threading;

class Program
{
    static void Main(string[] args)
    {
        int sleep = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("Sleeping...");
        Thread.Sleep(sleep); 
        Console.WriteLine("Awake!");
    }
}

Go: package main

import "time"
import "fmt"

func main() {
    fmt.Print("Enter number of seconds to sleep: ")
    var sec float64
    fmt.Scanf("%f", &sec)
    fmt.Print("Sleeping…")
    time.Sleep(time.Duration(sec * float64(time.Second)))
    fmt.Println("\nAwake!")
}
Task: Sleep
C#: using System;
using System.Threading;

class Program
{
    static void Main(string[] args)
    {
        int sleep = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("Sleeping...");
        Thread.Sleep(sleep); 
        Console.WriteLine("Awake!");
    }
}

Java: import java.util.InputMismatchException;
import java.util.Scanner;

public class Sleep {
    public static void main(final String[] args) throws InterruptedException {
        try {
            int ms = new Scanner(System.in).nextInt(); 
            System.out.println("Sleeping...");
            Thread.sleep(ms);
            System.out.println("Awake!");
        } catch (InputMismatchException inputMismatchException) {
            System.err.println("Exception: " + inputMismatchException);
        }
    }
}
Task: Sleep
C++: #include <iostream>
#include <thread>
#include <chrono>
int main()
{
    unsigned long microseconds;
    std::cin >> microseconds;
    std::cout << "Sleeping..." << std::endl;
    std::this_thread::sleep_for(std::chrono::microseconds(microseconds));
    std::cout << "Awake!\n";
}

Python: import time

seconds = float(raw_input())
print "Sleeping..."
time.sleep(seconds) 
print "Awake!"
Task: Sleep
Java: import java.util.InputMismatchException;
import java.util.Scanner;

public class Sleep {
    public static void main(final String[] args) throws InterruptedException {
        try {
            int ms = new Scanner(System.in).nextInt(); 
            System.out.println("Sleeping...");
            Thread.sleep(ms);
            System.out.println("Awake!");
        } catch (InputMismatchException inputMismatchException) {
            System.err.println("Exception: " + inputMismatchException);
        }
    }
}

VB: input "Enter the number of seconds to sleep: ";s
sleep s
print "I
input "Press enter to quit";a$
Task: Sleep
C: #include <stdio.h>
#include <unistd.h>

int main()
{
  unsigned int seconds;
  scanf("%u", &seconds);
  printf("Sleeping...\n");
  sleep(seconds);
  printf("Awake!\n");
  return 0;
}

PHP: $seconds = 42;
echo "Sleeping...\n";
sleep($seconds); # number is integer in seconds
echo "Awake!\n";
Task: Sleep
C#: using System;
using System.Threading;

class Program
{
    static void Main(string[] args)
    {
        int sleep = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("Sleeping...");
        Thread.Sleep(sleep); 
        Console.WriteLine("Awake!");
    }
}

PHP: $seconds = 42;
echo "Sleeping...\n";
sleep($seconds); # number is integer in seconds
echo "Awake!\n";
Task: Sleep
C++: #include <iostream>
#include <thread>
#include <chrono>
int main()
{
    unsigned long microseconds;
    std::cin >> microseconds;
    std::cout << "Sleeping..." << std::endl;
    std::this_thread::sleep_for(std::chrono::microseconds(microseconds));
    std::cout << "Awake!\n";
}

PHP: $seconds = 42;
echo "Sleeping...\n";
sleep($seconds); # number is integer in seconds
echo "Awake!\n";
Task: Sleep
Go: package main

import "time"
import "fmt"

func main() {
    fmt.Print("Enter number of seconds to sleep: ")
    var sec float64
    fmt.Scanf("%f", &sec)
    fmt.Print("Sleeping…")
    time.Sleep(time.Duration(sec * float64(time.Second)))
    fmt.Println("\nAwake!")
}

PHP: $seconds = 42;
echo "Sleeping...\n";
sleep($seconds); # number is integer in seconds
echo "Awake!\n";
Task: Sleep
Java: import java.util.InputMismatchException;
import java.util.Scanner;

public class Sleep {
    public static void main(final String[] args) throws InterruptedException {
        try {
            int ms = new Scanner(System.in).nextInt(); 
            System.out.println("Sleeping...");
            Thread.sleep(ms);
            System.out.println("Awake!");
        } catch (InputMismatchException inputMismatchException) {
            System.err.println("Exception: " + inputMismatchException);
        }
    }
}

PHP: $seconds = 42;
echo "Sleeping...\n";
sleep($seconds); # number is integer in seconds
echo "Awake!\n";
Task: Sleep
Python: import time

seconds = float(raw_input())
print "Sleeping..."
time.sleep(seconds) 
print "Awake!"

PHP: $seconds = 42;
echo "Sleeping...\n";
sleep($seconds); # number is integer in seconds
echo "Awake!\n";
Task: Sleep
VB: input "Enter the number of seconds to sleep: ";s
sleep s
print "I
input "Press enter to quit";a$

PHP: $seconds = 42;
echo "Sleeping...\n";
sleep($seconds); # number is integer in seconds
echo "Awake!\n";
Task: 100 doors
C: #include <stdio.h>

int main()
{
  char is_open[100] = { 0 };
  int pass, door;

  
  for (pass = 0; pass < 100; ++pass)
    for (door = pass; door < 100; door += pass+1)
      is_open[door] = !is_open[door];

  
  for (door = 0; door < 100; ++door)
    printf("door #%d is %s.\n", door+1, (is_open[door]? "open" : "closed"));

  return 0;
}

C++: #include <iostream>

int main()
{
  bool is_open[100] = { false };

  
  for (int pass = 0; pass < 100; ++pass)
    for (int door = pass; door < 100; door += pass+1)
      is_open[door] = !is_open[door];

  
  for (int door = 0; door < 100; ++door)
    std::cout << "door #" << door+1 << (is_open[door]? " is open." : " is closed.") << std::endl;
  return 0;
}
Task: 100 doors
C: #include <stdio.h>

int main()
{
  char is_open[100] = { 0 };
  int pass, door;

  
  for (pass = 0; pass < 100; ++pass)
    for (door = pass; door < 100; door += pass+1)
      is_open[door] = !is_open[door];

  
  for (door = 0; door < 100; ++door)
    printf("door #%d is %s.\n", door+1, (is_open[door]? "open" : "closed"));

  return 0;
}

Java: module OneHundredDoors
    {
    @Inject Console console;

    void run()
        {
        Boolean[] doors = new Boolean[100];
        for (Int pass : 0 ..< 100)
            {
            for (Int door = pass; door < 100; door += 1+pass)
                {
                doors[door] = !doors[door];
                }
            }

        console.print($"open doors: {doors.mapIndexed((d, i) -> d ? i+1 : 0).filter(i -> i > 0)}");
        }
    }
Task: 100 doors
C: #include <stdio.h>

int main()
{
  char is_open[100] = { 0 };
  int pass, door;

  
  for (pass = 0; pass < 100; ++pass)
    for (door = pass; door < 100; door += pass+1)
      is_open[door] = !is_open[door];

  
  for (door = 0; door < 100; ++door)
    printf("door #%d is %s.\n", door+1, (is_open[door]? "open" : "closed"));

  return 0;
}

Python: var doors = falses(100)

for a in 1..100: for b in a..a..100:
    doors[b] = not doors[b]

for a in 1..100:
    print "Door $a is ${(doors[a]) ? 'open.': 'closed.'}"
Task: 100 doors
C: #include <stdio.h>

int main()
{
  char is_open[100] = { 0 };
  int pass, door;

  
  for (pass = 0; pass < 100; ++pass)
    for (door = pass; door < 100; door += pass+1)
      is_open[door] = !is_open[door];

  
  for (door = 0; door < 100; ++door)
    printf("door #%d is %s.\n", door+1, (is_open[door]? "open" : "closed"));

  return 0;
}

VB: dim x as integer, y as integer
dim door(1 to 100) as byte


for x = 1 to 100 : door(x) = 0 : next


for y = 1 to 100
    for x = y to 100 step y
        door(x) = not door(x)
    next x
next y


for x = 1 to 100
    if door(x) then print "Door " + str$(x) + " = open"
next 

while inkey$="":wend
end
Task: 100 doors
C++: #include <iostream>

int main()
{
  bool is_open[100] = { false };

  
  for (int pass = 0; pass < 100; ++pass)
    for (int door = pass; door < 100; door += pass+1)
      is_open[door] = !is_open[door];

  
  for (int door = 0; door < 100; ++door)
    std::cout << "door #" << door+1 << (is_open[door]? " is open." : " is closed.") << std::endl;
  return 0;
}

Java: module OneHundredDoors
    {
    @Inject Console console;

    void run()
        {
        Boolean[] doors = new Boolean[100];
        for (Int pass : 0 ..< 100)
            {
            for (Int door = pass; door < 100; door += 1+pass)
                {
                doors[door] = !doors[door];
                }
            }

        console.print($"open doors: {doors.mapIndexed((d, i) -> d ? i+1 : 0).filter(i -> i > 0)}");
        }
    }
Task: 100 doors
C++: #include <iostream>

int main()
{
  bool is_open[100] = { false };

  
  for (int pass = 0; pass < 100; ++pass)
    for (int door = pass; door < 100; door += pass+1)
      is_open[door] = !is_open[door];

  
  for (int door = 0; door < 100; ++door)
    std::cout << "door #" << door+1 << (is_open[door]? " is open." : " is closed.") << std::endl;
  return 0;
}

Python: var doors = falses(100)

for a in 1..100: for b in a..a..100:
    doors[b] = not doors[b]

for a in 1..100:
    print "Door $a is ${(doors[a]) ? 'open.': 'closed.'}"
Task: 100 doors
C++: #include <iostream>

int main()
{
  bool is_open[100] = { false };

  
  for (int pass = 0; pass < 100; ++pass)
    for (int door = pass; door < 100; door += pass+1)
      is_open[door] = !is_open[door];

  
  for (int door = 0; door < 100; ++door)
    std::cout << "door #" << door+1 << (is_open[door]? " is open." : " is closed.") << std::endl;
  return 0;
}

VB: dim x as integer, y as integer
dim door(1 to 100) as byte


for x = 1 to 100 : door(x) = 0 : next


for y = 1 to 100
    for x = y to 100 step y
        door(x) = not door(x)
    next x
next y


for x = 1 to 100
    if door(x) then print "Door " + str$(x) + " = open"
next 

while inkey$="":wend
end
Task: 100 doors
Java: module OneHundredDoors
    {
    @Inject Console console;

    void run()
        {
        Boolean[] doors = new Boolean[100];
        for (Int pass : 0 ..< 100)
            {
            for (Int door = pass; door < 100; door += 1+pass)
                {
                doors[door] = !doors[door];
                }
            }

        console.print($"open doors: {doors.mapIndexed((d, i) -> d ? i+1 : 0).filter(i -> i > 0)}");
        }
    }

Python: var doors = falses(100)

for a in 1..100: for b in a..a..100:
    doors[b] = not doors[b]

for a in 1..100:
    print "Door $a is ${(doors[a]) ? 'open.': 'closed.'}"
Task: 100 doors
Java: module OneHundredDoors
    {
    @Inject Console console;

    void run()
        {
        Boolean[] doors = new Boolean[100];
        for (Int pass : 0 ..< 100)
            {
            for (Int door = pass; door < 100; door += 1+pass)
                {
                doors[door] = !doors[door];
                }
            }

        console.print($"open doors: {doors.mapIndexed((d, i) -> d ? i+1 : 0).filter(i -> i > 0)}");
        }
    }

VB: dim x as integer, y as integer
dim door(1 to 100) as byte


for x = 1 to 100 : door(x) = 0 : next


for y = 1 to 100
    for x = y to 100 step y
        door(x) = not door(x)
    next x
next y


for x = 1 to 100
    if door(x) then print "Door " + str$(x) + " = open"
next 

while inkey$="":wend
end
Task: 100 doors
Python: var doors = falses(100)

for a in 1..100: for b in a..a..100:
    doors[b] = not doors[b]

for a in 1..100:
    print "Door $a is ${(doors[a]) ? 'open.': 'closed.'}"

VB: dim x as integer, y as integer
dim door(1 to 100) as byte


for x = 1 to 100 : door(x) = 0 : next


for y = 1 to 100
    for x = y to 100 step y
        door(x) = not door(x)
    next x
next y


for x = 1 to 100
    if door(x) then print "Door " + str$(x) + " = open"
next 

while inkey$="":wend
end
Task: Averages_Mean time of day
C: #include<stdlib.h>
#include<math.h>
#include<stdio.h>

typedef struct
{
  int hour, minute, second;
} digitime;

double
timeToDegrees (digitime time)
{
  return (360 * time.hour / 24.0 + 360 * time.minute / (24 * 60.0) +
          360 * time.second / (24 * 3600.0));
}

digitime
timeFromDegrees (double angle)
{
  digitime d;
  double totalSeconds = 24 * 60 * 60 * angle / 360;

  d.second = (int) totalSeconds % 60;
  d.minute = ((int) totalSeconds % 3600 - d.second) / 60;
  d.hour = (int) totalSeconds / 3600;

  return d;
}

double
meanAngle (double *angles, int size)
{
  double y_part = 0, x_part = 0;
  int i;

  for (i = 0; i < size; i++)
    {
      x_part += cos (angles[i] * M_PI / 180);
      y_part += sin (angles[i] * M_PI / 180);
    }

  return atan2 (y_part / size, x_part / size) * 180 / M_PI;
}

int
main ()
{
  digitime *set, meanTime;
  int inputs, i;
  double *angleSet, angleMean;

  printf ("Enter number of inputs : ");
  scanf ("%d", &inputs);
  set = malloc (inputs * sizeof (digitime));
  angleSet = malloc (inputs * sizeof (double));
  printf ("\n\nEnter the data separated by a space between each unit : ");

  for (i = 0; i < inputs; i++)
    {
      scanf ("%d:%d:%d", &set[i].hour, &set[i].minute, &set[i].second);
      angleSet[i] = timeToDegrees (set[i]);
    }

  meanTime = timeFromDegrees (360 + meanAngle (angleSet, inputs));

  printf ("\n\nThe mean time is : %d:%d:%d", meanTime.hour, meanTime.minute,
          meanTime.second);
  return 0;
}

C#: using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Math;

namespace RosettaCode;

class Program
{
    private const int SecondsPerDay = 60 * 60 * 24;

    static void Main()
    {
        var digitimes = new List<TimeSpan>();

        Console.WriteLine("Enter times, end with no input: ");
        while (true) {
            string input = Console.ReadLine();
            if (string.IsNullOrWhiteSpace(input)) break;
            if (TimeSpan.TryParse(input, out var digitime)) {
                digitimes.Add(digitime);
            } else {
                Console.WriteLine("Seems this is wrong input: ignoring time");
            }
        }
        if(digitimes.Count() > 0)
            Console.WriteLine($"The mean time is : {MeanTime(digitimes)}");
    }

    public static TimeSpan MeanTime(IEnumerable<TimeSpan> ts) => FromDegrees(MeanAngle(ts.Select(ToDegrees)));
    public static double ToDegrees(TimeSpan ts) => ts.TotalSeconds * 360d / SecondsPerDay;
    public static TimeSpan FromDegrees(double degrees) => TimeSpan.FromSeconds((int)(degrees * SecondsPerDay / 360));

    public static double MeanAngle(IEnumerable<double> angles)
    {
        var x = angles.Average(a => Cos(a * PI / 180));
        var y = angles.Average(a => Sin(a * PI / 180));
        return (Atan2(y, x) * 180 / PI + 360) % 360;
    }
}
Task: Averages_Mean time of day
C: #include<stdlib.h>
#include<math.h>
#include<stdio.h>

typedef struct
{
  int hour, minute, second;
} digitime;

double
timeToDegrees (digitime time)
{
  return (360 * time.hour / 24.0 + 360 * time.minute / (24 * 60.0) +
          360 * time.second / (24 * 3600.0));
}

digitime
timeFromDegrees (double angle)
{
  digitime d;
  double totalSeconds = 24 * 60 * 60 * angle / 360;

  d.second = (int) totalSeconds % 60;
  d.minute = ((int) totalSeconds % 3600 - d.second) / 60;
  d.hour = (int) totalSeconds / 3600;

  return d;
}

double
meanAngle (double *angles, int size)
{
  double y_part = 0, x_part = 0;
  int i;

  for (i = 0; i < size; i++)
    {
      x_part += cos (angles[i] * M_PI / 180);
      y_part += sin (angles[i] * M_PI / 180);
    }

  return atan2 (y_part / size, x_part / size) * 180 / M_PI;
}

int
main ()
{
  digitime *set, meanTime;
  int inputs, i;
  double *angleSet, angleMean;

  printf ("Enter number of inputs : ");
  scanf ("%d", &inputs);
  set = malloc (inputs * sizeof (digitime));
  angleSet = malloc (inputs * sizeof (double));
  printf ("\n\nEnter the data separated by a space between each unit : ");

  for (i = 0; i < inputs; i++)
    {
      scanf ("%d:%d:%d", &set[i].hour, &set[i].minute, &set[i].second);
      angleSet[i] = timeToDegrees (set[i]);
    }

  meanTime = timeFromDegrees (360 + meanAngle (angleSet, inputs));

  printf ("\n\nThe mean time is : %d:%d:%d", meanTime.hour, meanTime.minute,
          meanTime.second);
  return 0;
}

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

#define _USE_MATH_DEFINES
#include <math.h>

struct Time {
    int hour, minute, second;

    friend std::ostream &operator<<(std::ostream &, const Time &);
};

std::ostream &operator<<(std::ostream &os, const Time &t) {
    return os << std::setfill('0')
        << std::setw(2) << t.hour << ':'
        << std::setw(2) << t.minute << ':'
        << std::setw(2) << t.second;
}

double timeToDegrees(Time &&t) {
    return 360.0 * t.hour / 24.0
        + 360.0 * t.minute / (24 * 60.0)
        + 360.0 * t.second / (24 * 3600.0);
}

Time degreesToTime(double angle) {
    while (angle < 0.0) {
        angle += 360.0;
    }
    while (angle > 360.0) {
        angle -= 360.0;
    }

    double totalSeconds = 24.0 * 60 * 60 * angle / 360;
    Time t;

    t.second = (int)totalSeconds % 60;
    t.minute = ((int)totalSeconds % 3600 - t.second) / 60;
    t.hour = (int)totalSeconds / 3600;

    return t;
}

double meanAngle(const std::vector<double> &angles) {
    double yPart = 0.0, xPart = 0.0;
    for (auto a : angles) {
        xPart += cos(a * M_PI / 180);
        yPart += sin(a * M_PI / 180);
    }
    return atan2(yPart / angles.size(), xPart / angles.size()) * 180 / M_PI;
}

int main() {
    std::vector<double> tv;
    tv.push_back(timeToDegrees({ 23, 0, 17 }));
    tv.push_back(timeToDegrees({ 23, 40, 20 }));
    tv.push_back(timeToDegrees({ 0, 12, 45 }));
    tv.push_back(timeToDegrees({ 0, 17, 19 }));

    double ma = meanAngle(tv);
    auto mt = degreesToTime(ma);
    std::cout << mt << '\n';

    return 0;
}
Task: Averages_Mean time of day
C: #include<stdlib.h>
#include<math.h>
#include<stdio.h>

typedef struct
{
  int hour, minute, second;
} digitime;

double
timeToDegrees (digitime time)
{
  return (360 * time.hour / 24.0 + 360 * time.minute / (24 * 60.0) +
          360 * time.second / (24 * 3600.0));
}

digitime
timeFromDegrees (double angle)
{
  digitime d;
  double totalSeconds = 24 * 60 * 60 * angle / 360;

  d.second = (int) totalSeconds % 60;
  d.minute = ((int) totalSeconds % 3600 - d.second) / 60;
  d.hour = (int) totalSeconds / 3600;

  return d;
}

double
meanAngle (double *angles, int size)
{
  double y_part = 0, x_part = 0;
  int i;

  for (i = 0; i < size; i++)
    {
      x_part += cos (angles[i] * M_PI / 180);
      y_part += sin (angles[i] * M_PI / 180);
    }

  return atan2 (y_part / size, x_part / size) * 180 / M_PI;
}

int
main ()
{
  digitime *set, meanTime;
  int inputs, i;
  double *angleSet, angleMean;

  printf ("Enter number of inputs : ");
  scanf ("%d", &inputs);
  set = malloc (inputs * sizeof (digitime));
  angleSet = malloc (inputs * sizeof (double));
  printf ("\n\nEnter the data separated by a space between each unit : ");

  for (i = 0; i < inputs; i++)
    {
      scanf ("%d:%d:%d", &set[i].hour, &set[i].minute, &set[i].second);
      angleSet[i] = timeToDegrees (set[i]);
    }

  meanTime = timeFromDegrees (360 + meanAngle (angleSet, inputs));

  printf ("\n\nThe mean time is : %d:%d:%d", meanTime.hour, meanTime.minute,
          meanTime.second);
  return 0;
}

Java: public class MeanTimeOfDay {
    
    static double meanAngle(double[] angles) {
        int len = angles.length;
        double sinSum = 0.0;
        for (int i = 0; i < len; i++) {
            sinSum += Math.sin(angles[i] * Math.PI / 180.0);
        }
 
        double cosSum = 0.0;
        for (int i = 0; i < len; i++) {
            cosSum += Math.cos(angles[i] * Math.PI / 180.0);
        }

        return Math.atan2(sinSum / len, cosSum / len) * 180.0 / Math.PI;
    }

    
    static int timeToSecs(String t) {
        int hours = Integer.parseInt(t.substring(0, 2));
        int mins  = Integer.parseInt(t.substring(3, 5));
        int secs  = Integer.parseInt(t.substring(6, 8));
        return 3600 * hours + 60 * mins + secs;
    }

    
    static double timeToDegrees(String t) {
        return timeToSecs(t) / 240.0;
    }

    static String degreesToTime(double d) {
        if (d < 0.0) d += 360.0;
        int secs  = (int)(d * 240.0);
        int hours = secs / 3600;
        int mins  = secs % 3600;
        secs = mins % 60;
        mins /= 60;
        return String.format("%2d:%2d:%2d", hours, mins, secs);
    }

    public static void main(String[] args) {
        String[] tm = {"23:00:17", "23:40:20", "00:12:45", "00:17:19"};
        double[] angles = new double[4];
        for (int i = 0; i < 4; i++) angles[i] = timeToDegrees(tm[i]);        
        double mean = meanAngle(angles);
        System.out.println("Average time is : " + degreesToTime(mean));
    }
}
Task: Averages_Mean time of day
C: #include<stdlib.h>
#include<math.h>
#include<stdio.h>

typedef struct
{
  int hour, minute, second;
} digitime;

double
timeToDegrees (digitime time)
{
  return (360 * time.hour / 24.0 + 360 * time.minute / (24 * 60.0) +
          360 * time.second / (24 * 3600.0));
}

digitime
timeFromDegrees (double angle)
{
  digitime d;
  double totalSeconds = 24 * 60 * 60 * angle / 360;

  d.second = (int) totalSeconds % 60;
  d.minute = ((int) totalSeconds % 3600 - d.second) / 60;
  d.hour = (int) totalSeconds / 3600;

  return d;
}

double
meanAngle (double *angles, int size)
{
  double y_part = 0, x_part = 0;
  int i;

  for (i = 0; i < size; i++)
    {
      x_part += cos (angles[i] * M_PI / 180);
      y_part += sin (angles[i] * M_PI / 180);
    }

  return atan2 (y_part / size, x_part / size) * 180 / M_PI;
}

int
main ()
{
  digitime *set, meanTime;
  int inputs, i;
  double *angleSet, angleMean;

  printf ("Enter number of inputs : ");
  scanf ("%d", &inputs);
  set = malloc (inputs * sizeof (digitime));
  angleSet = malloc (inputs * sizeof (double));
  printf ("\n\nEnter the data separated by a space between each unit : ");

  for (i = 0; i < inputs; i++)
    {
      scanf ("%d:%d:%d", &set[i].hour, &set[i].minute, &set[i].second);
      angleSet[i] = timeToDegrees (set[i]);
    }

  meanTime = timeFromDegrees (360 + meanAngle (angleSet, inputs));

  printf ("\n\nThe mean time is : %d:%d:%d", meanTime.hour, meanTime.minute,
          meanTime.second);
  return 0;
}

Python: from cmath import rect, phase
from math import radians, degrees


def mean_angle(deg):
    return degrees(phase(sum(rect(1, radians(d)) for d in deg)/len(deg)))

def mean_time(times):
    t = (time.split(':') for time in times)
    seconds = ((float(s) + int(m) * 60 + int(h) * 3600) 
               for h, m, s in t)
    day = 24 * 60 * 60
    to_angles = [s * 360. / day for s in seconds]
    mean_as_angle = mean_angle(to_angles)
    mean_seconds = mean_as_angle * day / 360.
    if mean_seconds < 0:
        mean_seconds += day
    h, m = divmod(mean_seconds, 3600)
    m, s = divmod(m, 60)
    return '%02i:%02i:%02i' % (h, m, s)


if __name__ == '__main__':
    print( mean_time(["23:00:17", "23:40:20", "00:12:45", "00:17:19"]) )