1 2 3 4 5 6 7 8 9 10 11 12 | import std.stdio; void main() { auto lines = 0; auto sumLength = 0; foreach (line; stdin.byLine()) { ++lines; sumLength += line.length; } writeln("Average line length: ", lines ? sumLength / lines : 0); } |
aW1wb3J0IHN0ZC5zdGRpbzsKCnZvaWQgbWFpbigpIHsKICAgIGF1dG8gbGluZXMgPSAwOwogICAgYXV0byBzdW1MZW5ndGggPSAwOwogICAgZm9yZWFjaCAobGluZTsgc3RkaW4uYnlMaW5lKCkpIHsKICAgICAgICArK2xpbmVzOwogICAgICAgIHN1bUxlbmd0aCArPSBsaW5lLmxlbmd0aDsKICAgIH0KICAgIHdyaXRlbG4oIkF2ZXJhZ2UgbGluZSBsZW5ndGg6ICIsCiAgICAgICAgbGluZXMgPyBzdW1MZW5ndGggLyBsaW5lcyA6IDApOwp9
-
upload with new input
-
result: Success time: 0.01s memory: 2128 kB returned value: 0
1 2 3 4 5 6 7 8 9
Average line length: 17
-
result: Success time: 0.01s memory: 2128 kB returned value: 0
Average line length: 0



