-
Лучший говнокод
- В номинации:
-
- За время:
-
-
+9
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
#define public public: void operator delete(void *pituh) {}; public
class poteklo
{
public:
poteklo() :
TheAnswer(42)
{
;
}
private:
int TheAnswer;
};
int main(int argc, char *argv[])
{
poteklo *uteklo = new poteklo;
delete uteklo; // Утекло!
return 0;
}
Макро в духе "#define TRUE FALSE", только хардкорнее.
https://ideone.com/ZdGnuL
gost,
30 Мая 2016
-
0
- 1
Тарас с сайта ebanoe.it это не я
TarasB,
11 Мая 2016
-
+168
- 1
define("OUTPUT_DIR_CSV", "kokoko/kukarek/files" . DIRECTORY_SEPARATOR);
Stallman,
19 Февраля 2015
-
+156
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
(function(G, D) {
"use strict";
var $ = G.jQuery,
listener;
function addListener(elem, fn) {
function handler(event) {
event = event || G.event;
var dx = event.DeltaX || event.wheelDeltaX || event.detail || 0,
dy = event.DeltaY || event.wheelDeltaY || event.detail || 0;
event.dx = dx === 0 ? 0 : dx / Math.abs(dx);
event.dy = dy === 0 ? 0 : dy / Math.abs(dy);
fn(event);
}
if (elem.addEventListener) {
if (D.hasOwnProperty('onwheel')) { //Modern browsers
listener = "wheel";
} else if (D.hasOwnProperty('onmousewheel')) { //Old browsers
listener = "mousewheel";
} else { //FF<17
listener = "MozMousePixelScroll";
}
elem.addEventListener(listener, handler, false);
} else { //IE<9
elem.attachEvent("onmousewheel", handler);
listener = "onmousewheel";
}
}
function removeListener(elem) {
if (elem.removeEventListener) {
elem.removeEventListener(listener);
} else {
elem.detachEvent(listener);
}
}
$.fn.mousewheel = function(fn) {
return this.each(function() {
addListener(this, fn);
});
};
$.fn.unmousewheel = function(fn) {
return this.each(function() {
removeListener(this, fn, false);
});
};
}(this, document));
Написал плагин для jQuery, который цепляет на элементы обработчик события вращения колесика мыши. Что скажете? Как бы вы написали функцию unmousewheel()?
dunmaksim,
10 Июня 2014
-
+135
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
private void Button2_Click(object sender, EventArgs e)
{
this.Label4.Text = new StreamReader("C:\\Program Files\\Microsoft Visual Studio 10.0\\VB\\VBProjects\\датаметр\\датаметр\\bin\\Release\\Key.txt").ReadLine();
if (Operators.CompareString(this.Label4.Text, "vrc5rhhgyuuoxr45", false) == 0)
{
this.Button1.Visible = true;
this.TextBox1.Visible = true;
this.Label1.Visible = true;
this.Label4.Visible = false;
this.Button2.Visible = false;
this.Label3.Visible = true;
int num = (int) Interaction.MsgBox((object) "Ключ верный.\r\nНе сообщайте его никому !!\r\nИ не потеряйте.", MsgBoxStyle.OkOnly, (object) null);
}
else
this.Label4.Text = "Ключ не верный !!\r\nПоменяйте его в файле \"Key\"";
}
Классное расположение файла. Причём в архиве лежит пустой файл Key.txt рядом с программой...
Как надо было извратиться, чтобы в коде оказался не просто абсолютный путь, но и вот такой-вот с Program Files, ведь по умолчанию VS создаёт проекты в Моих документах
http://www.cyberforum.ru/vb-net/thread971437.html
Qwertiy,
08 Октября 2013
-
+134
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
using System;
using System.Security.Cryptography;
namespace sha1_calc
{
class Program
{
static void Main(string[] args)
{
SHA1 sha = new SHA1CryptoServiceProvider();
foreach (var fname in args)
{
Console.WriteLine("file: " + fname);
try
{
System.IO.FileStream fs = System.IO.File.Create(fname);
byte [] res = sha.ComputeHash(fs);
fs.Close();
Console.Write("0x");
foreach (var i in res)
{
Console.Write(i.ToString("X"));
}
Console.WriteLine();
Console.WriteLine("---------------------------------");
}
catch(Exception e)
{
Console.WriteLine("error: " + e);
}
}
Console.ReadKey();
}
}
}
Скачал парочку образов и решил проверить их чексуммы. Протестировал программу на скачанных файлах. Удивился, почему же у них хеши одинаковые?
Xom94ok,
05 Июля 2013
-
+97
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
program Project42;
{$APPTYPE CONSOLE}
uses
SysUtils, Math;
const
Radix = 10;
function čòũʼnť(N: Integer): Integer;
begin
Result := 0;
while N > 0 do
begin
N := N div Radix;
Inc(Result);
end;
end;
function count(N: Integer): Integer;
begin
// Result := Ceil(LogN(Radix, N)); { slow! }
Result := Ceil(Log10(N));
end;
function rdtsc: Int64;
asm
rdtsc
end;
var
I: Integer;
t0: Int64;
const
N = 100500;
begin
try
Assert((count(42) = čòũʼnť(42)) and (count(100500) = čòũʼnť(100500)));
t0 := rdtsc;
for I := 1 to N do
čòũʼnť(Random(MaxInt + 1));
Writeln('naïve: ', rdtsc - t0, ' ticks');
t0 := rdtsc;
for I := 1 to N do
count(Random(MaxInt + 1));
Writeln('prőper: ', rdtsc - t0, ' ticks');
Writeln(StringOfChar('-', 42));
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
if DebugHook <> 0 then
begin
Write('any big key to exit...');
Readln;
end;
end.
{ http://imgs.xkcd.com/comics/haiku_proof.png :-P }
матан > метан
O(1) > O(N)
логарифм > байтоёбства с делением
bugmenot,
01 Декабря 2010
-
0
#94: https://govnokod.ru/28895 https://govnokod.xyz/_28895
#95: https://govnokod.ru/28904 https://govnokod.xyz/_28904
#96: https://govnokod.ru/28912 https://govnokod.xyz/_28912
#97: https://govnokod.ru/28918 https://govnokod.xyz/_28918
#98: https://govnokod.ru/28932 https://govnokod.xyz/_28932
#99: https://govnokod.ru/28936 https://govnokod.xyz/_28936
#100: https://govnokod.ru/28940 https://govnokod.xyz/_28940
#101: https://govnokod.ru/28949 https://govnokod.xyz/_28949
#102: https://govnokod.ru/28978 https://govnokod.xyz/_28978
#103: https://govnokod.ru/28982 https://govnokod.xyz/_28982
#104: https://govnokod.ru/28989 https://govnokod.xyz/_28989
#105: https://govnokod.ru/29052 https://govnokod.xyz/_29052
#106: https://govnokod.ru/29069 https://govnokod.xyz/_29069
#107: https://govnokod.ru/29086 https://govnokod.xyz/_29086
#108: https://govnokod.ru/29102 https://govnokod.xyz/_29102
#109: https://govnokod.ru/29126 https://govnokod.xyz/_29126
#110: https://govnokod.ru/29136 https://govnokod.xyz/_29136
#111: https://govnokod.ru/29142 https://govnokod.xyz/_29142
#112: https://govnokod.ru/29155 https://govnokod.xyz/_29155
#113: https://govnokod.ru/29160 https://govnokod.xyz/_29160
#114: https://govnokod.ru/29165 https://govnokod.xyz/_29165
#115: https://govnokod.ru/29173 https://govnokod.xyz/_29173
#116: https://govnokod.ru/29174 https://govnokod.xyz/_29174
#117: https://govnokod.ru/29182 https://govnokod.xyz/_29182
#118: https://govnokod.ru/29191 https://govnokod.xyz/_29191
#119: https://govnokod.ru/29196 https://govnokod.xyz/_29196
#120: https://govnokod.ru/29205 https://govnokod.xyz/_29205
#121: https://govnokod.ru/29216 https://govnokod.xyz/_29216
#122: https://govnokod.ru/29219 https://govnokod.xyz/_29219
#123: https://govnokod.ru/29232 https://govnokod.xyz/_29232
nepeKamHblu_nemyx,
01 Марта 2026
-
+1
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a[4] = {1, 2, 3, 4};
int (*a_p1)[4] = (int (*)[4])a;
int (*a_p2)[4] = &a;
for(size_t i = 0; i < 4; ++i)
{
printf("%p -> %d; %p -> %d\n", &(*a_p1)[i], (*a_p1)[i], &(*a_p1)[i], (*a_p2)[i]);
}
return EXIT_SUCCESS;
}
Вот такой вывод:
0x7ffee4ebd950 -> 1; 0x7ffee4ebd950 -> 1
0x7ffee4ebd954 -> 2; 0x7ffee4ebd954 -> 2
0x7ffee4ebd958 -> 3; 0x7ffee4ebd958 -> 3
0x7ffee4ebd95c -> 4; 0x7ffee4ebd95c -> 4
j123123,
14 Января 2022
-
0
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
pub fn take(end: u32) -> u32
{
(0..).step_by(1000000000)
.map(|i| i * i)
.take_while(|&i| i < end)
.sum()
}
pub fn filter(end: u32) -> u32
{
(0..).step_by(1000000000)
.map(|i| i * i)
.filter(|&i| i < end)
.sum()
}
Решил вернуться к изучению багра rust.
Суть такова: код с take_while выводит 0, код с filter падает с runtime error или выбрасывается rustClang как бесконечный цикл (зависит от версии).
https://ideone.com/IS05Q0
То есть код filter ма-те-ма-ти-че-ски эквивалентен take_while. Поскольку i² монотонно возрастающая функция.
Из примера ниже можно убедиться что цикл на самом деле конечен.
https://ideone.com/xC2r35
Счётчик кидает ошибку при переполнении и range не зацикливается.
for x in (1..).step_by(1000000000) {
println!("{}", x);
}
1
1000000001
2000000001
Runtime error #stdin #stdout #stderr 0.01s 5552KB
3.14159265,
05 Сентября 2021