-
-
Save henrikh/173359 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0100110101000001010001010100101100100000010001100101010101001110010000110101010001001001010011110100111000001101000010100010000000100000001000000010000001000111010100100100000101001110010101000010000001000001010000100100100101001100010010010101010001011001001000000011111000111110001000000101000001000001010100100100000101001101010001010101010001000101010100100101001100001101000010100010000000100000001000000010000001000111010100100100000101001110010101000010000001000001010000100100100101001100010010010101010001011001001000000011111000111110001000000101001101010101010011010100111101000110010100000100000101010010010000010100110101000101010101000100010101010010010100110000110100001010001000000010000000100000001000000100011101010010010000010100111001010100001000000100000101000010010010010100110001001001010101000101100100100000001111100011111000100000010011100101010101001101010011110100011001010000010000010101001001000001010011010100010101010100010001010101001001010011000011010000101000001101000010100010000000100000001000000010000001010010010001010101010001010101010100100100111000100000010100110101010101001101010011110100011001010000010000010101001001000001010011010100010101010100010001010101001001010011001011110100111001010101010011010100111101000110010100000100000101010010010000010100110101000101010101000100010101010010010100110000110100001010010010110101010001001000010110000100001001011001010001010000110100001010 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdarg.h> | |
double average(int count, ...) | |
{ | |
va_list ap; | |
int j; | |
double tot = 0; | |
va_start(ap, count); | |
for(j=0; j<count; j++) | |
tot+=va_arg(ap, double); | |
va_end(ap); | |
return tot/count; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double Average(params double[] a) | |
{ | |
double sum = 0, count = 0; | |
foreach(int i in a) | |
{ | |
sum += i; | |
count ++; | |
} | |
return sum/count; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function average(){ | |
numbers=average.arguments; | |
sum=0; | |
for(var i=0; i<numbers.length; i++){ | |
sum+=numbers[i] | |
}; | |
return sum/numbers.length; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static double average(int... numbers) { | |
// Needs Java 1.5 | |
double count = 0; | |
double sum = 0; | |
for(int num: numbers) { | |
count++; | |
sum += num; | |
} | |
return sum / count; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun average (&rest numbers) | |
(/ (apply #'+ numbers)(length numbers))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function average(...) | |
table.foreach({...}, function (_,v) n = n or 0 + tonumber(v) or 0 end) | |
return n / #{...} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub Average | |
{ | |
my $s = 0; | |
($s += $_) for @_; | |
return $s/scalar(@_); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function average() { | |
return floatval(array_sum(func_get_args())/func_num_args()); | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def average(*numbers): | |
return float(sum(numbers))/len(numbers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment